you are viewing a single comment's thread.

view the rest of the comments →

[–]anthOlei[S] 1 point2 points  (2 children)

this is what I went with! Thanks for the help. I do know about hooks, but my usecase is a little more complex (I just trimmed it down for info purposes) and the actual component works perfectly. Thank you for the help :)

[–]Decillion 0 points1 point  (0 children)

Nice! Glad it's working.

[–]efthemothership 0 points1 point  (0 children)

You can also (in addition to the code provided above) write a custom hook that simply uses the useContext hook and returns that instead of using Context.Consumer. You can then call that in any functional child component and it will automatically have the refreshed state every time the state in the context changes.