You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw that is possible to have it in render like: return ( <Consumer> {props => <h1> WOW </h1>} </Consumer> )
But im not really sure how to get it inside the componentDidMount or any other methods. I tried to look for it inside this.context or this.props.context but no luck..
Any ideas ?
Thank you
The text was updated successfully, but these errors were encountered:
And when exporting my components i just do export default withContext(Component)
Not sure if this is the best solution :-?? but would love to hear an opinion.
@razvan-soare Hey, what you could also try is to play with the wrapRootElement or wrapPageElement functions inside gatsby-browser.js—and wrapping the <Consumer> there.
However, an HOC seems like a good addition for this purpose. Feel free to submit a PR (adding this function to /src/store), otherwise I'll take care of this in the next couple days. Thanks!
Hey im trying to pass my context to all my pages.
I saw that is possible to have it in render like:
return ( <Consumer> {props => <h1> WOW </h1>} </Consumer> )
But im not really sure how to get it inside the componentDidMount or any other methods. I tried to look for it inside
this.context
orthis.props.context
but no luck..Any ideas ?
Thank you
The text was updated successfully, but these errors were encountered: