Probably the hardest part of React, for me, was getting used to the callbacks. Passing data up to the parent component using a function. It’s a little difficult to get used to if you haven’t encountered it already
I had gone through Structure and Interpretation of Computer Programming before, and feel like that gave me all the foundational stuff I needed to understand what React is doing. The new third edition is in JavaScript, and while I haven’t read it, I imagine that would be an even better match.
If there’s a parent component that has some data that it expects to always receive from its children, then that data should be in the parent’s state and the children should receive it as props. Even if it’s an unknown number of children. Don’t muck with useContext for basic inheritance stuff, you’ll mess with the render cycle for no good reason.
Now, if we’re talking about a very distant “top” component, that’s fine, it’s what it was made for. Although many people end up using stores if it’s some data with broad impact (like user data)
Probably the hardest part of React, for me, was getting used to the callbacks. Passing data up to the parent component using a function. It’s a little difficult to get used to if you haven’t encountered it already
Just shove it in the state! I watched a few react videos over the last TWO WHOLE DAYS, it works!! ;$
I had gone through Structure and Interpretation of Computer Programming before, and feel like that gave me all the foundational stuff I needed to understand what React is doing. The new third edition is in JavaScript, and while I haven’t read it, I imagine that would be an even better match.
deleted by creator
I think you’re being down voted because context should be used sparingly. You can pass data back up the parent chain through prop functions.
deleted by creator
If there’s a parent component that has some data that it expects to always receive from its children, then that data should be in the parent’s state and the children should receive it as props. Even if it’s an unknown number of children. Don’t muck with useContext for basic inheritance stuff, you’ll mess with the render cycle for no good reason.
Now, if we’re talking about a very distant “top” component, that’s fine, it’s what it was made for. Although many people end up using stores if it’s some data with broad impact (like user data)