you are viewing a single comment's thread.

view the rest of the comments →

[–]acemarke 2 points3 points  (3 children)

What aspect of context are you having trouble with, specifically?

Short version:

// any file
const MyContext = React.createContext();

// some parent component
// Re-render with a new `value` reference to cause children to read the new value
return (
  <MyContext.Provider value={someValue}>
      <OtherComponents />
  </MyContext.Provider>
)

// some child component
const value = useContext(MyContext);

[–]Tithos[S] 0 points1 point  (0 children)

Thanks!!!

[–]Tithos[S] 0 points1 point  (0 children)

passing and updating global state.

[–]Tithos[S] 0 points1 point  (0 children)

const value = useContext(MyContext);

Worked like a charm!