How to re-render all children to Show updated values.
Answered
Munchkin posted this in #help-forum
Original message was deleted.
Answered by Silver Marten
i don't fully understand your question but i think
https://react.dev/reference/react/useContext
useContext() might be the answer to this https://react.dev/reference/react/useContext
React automatically re-renders all the children that use a particular context starting from the provider that receives a different value. The previous and the next values are compared with theObject.iscomparison. Skipping re-renders withmemodoes not prevent the children receiving fresh context values.
5 Replies
Munchkin
bump
Munchkin
Could Middleware be the answer in this case?
Original message was deleted
Silver Marten
i don't fully understand your question but i think
https://react.dev/reference/react/useContext
useContext() might be the answer to this https://react.dev/reference/react/useContext
React automatically re-renders all the children that use a particular context starting from the provider that receives a different value. The previous and the next values are compared with theObject.iscomparison. Skipping re-renders withmemodoes not prevent the children receiving fresh context values.
Answer
@Silver Marten i don't fully understand your question but i think `useContext()` might be the answer to this
https://react.dev/reference/react/useContext
> React automatically re-renders all the children that use a particular context starting from the provider that receives a different value. The previous and the next values are compared with the `Object.is` comparison. Skipping re-renders with `memo` does not prevent the children receiving fresh context values.
Munchkin
I did look into that but it felt a bit backwards having to re-implement the function everytime.
Could i maybe try to load the variable before i even do the first render?
Could i maybe try to load the variable before i even do the first render?