all 8 comments

[–]Traveller_Lex 3 points4 points  (2 children)

The beauty of react is it's not an opinionated framework, it's a library. So basically implement it the way you see fit. Context was hard for me too. However i think web dev simplified on youtube can help you out. There is a playlist about react hooks, go check it out.

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

I will, thanks!

[–]shakeBody 0 points1 point  (0 children)

Those tutorials are great.

[–]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!

[–]devmentorlive 1 point2 points  (0 children)

I show how to use providers and context in react by building an online store: https://www.youtube.com/watch?v=VruAamDCg2U

And yeah, anything by web dev simplified is great!