Sorry if I missed something in the docs, but I can...
# help
a
Sorry if I missed something in the docs, but I can't seem to figure out how to access stack props inside functional stacks.
Copy code
const stackProps = { foo: 'bar' }
app.stack(MyStack, stackProps) // How do I access stackProps inside MyStack?
e
I’m a newbie, just starting to play with functional stacks. But if you’re trying to pass props from another stack, you can use
use
Copy code
export function ProviderStack({stack}) {
  ...
  return {
    someProp
  }
}
then in a consumer stack
Copy code
export function ConsumerStack({stack}) {
  const { someProp } = use(ProviderStack)

}
not 100% sure if this directly answers your question since yours is passing from app
a
I was trying to pass simple props from
app.node.tryGetContext()
in my
index.ts
. I think that was a pattern I saw in some CDK examples along the way... I ended up just using
app.node.tryGetContext()
directly in the functional stack instead of trying to pass the context values as stack props.
f
@Adam Biggs that works. I’ve also seen ppl create a “dummy” config stack, ie.
Copy code
export function ConfigStack({ app }: StackContext) {
  const xyz = app.node.tryGetContext();
  return { xyz };
}
And you can
use(ConfigStack)
in the ConsumerStack
It looks weird at first that u have an empty ConfigStack, but later on it will likely house SSM parameters, etc.
Hope that makes sense.
a
Makes sense, thanks @Frank. Absolutely loving SST by the way!