Adam Biggs
06/10/2022, 11:06 PMconst stackProps = { foo: 'bar' }
app.stack(MyStack, stackProps) // How do I access stackProps inside MyStack?
Eu Jin Kim
06/11/2022, 12:08 AMuse
export function ProviderStack({stack}) {
...
return {
someProp
}
}
then in a consumer stack
export function ConsumerStack({stack}) {
const { someProp } = use(ProviderStack)
}
not 100% sure if this directly answers your question since yours is passing from appAdam Biggs
06/11/2022, 12:23 AMapp.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.Frank
export function ConfigStack({ app }: StackContext) {
const xyz = app.node.tryGetContext();
return { xyz };
}
And you can use(ConfigStack)
in the ConsumerStackFrank
Frank
Adam Biggs
06/13/2022, 3:57 PM