You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm creating this issue to propose an enhancement over how we pass state to components. Instead of having to pass it for all components, we would only need to pass it to the top-level ones.
For example, currently we have to pass the state to all instances of MenuItem inside Menu:
I'm proposing that we improve this so we don't need to explicitly pass state to MenuItem instances anymore. It would leverage React Context and subscribe to state changes internally.
Note: MenuItem should keep accepting state being passed directly as props for this reason. But it wouldn't be required anymore.
Motivation
Besides being easier to write code like that, it would also make it easier to colocate state.
In our Menu example, all MenuItem components will re-render when state gets updated. But if we abstract the state into a separate component that receives children, they won't re-render:
I'm creating this issue to propose an enhancement over how we pass state to components. Instead of having to pass it for all components, we would only need to pass it to the top-level ones.
For example, currently we have to pass the state to all instances of
MenuItem
insideMenu
:I'm proposing that we improve this so we don't need to explicitly pass state to
MenuItem
instances anymore. It would leverage React Context and subscribe to state changes internally.Note:
MenuItem
should keep accepting state being passed directly as props for this reason. But it wouldn't be required anymore.Motivation
Besides being easier to write code like that, it would also make it easier to colocate state.
In our
Menu
example, allMenuItem
components will re-render whenstate
gets updated. But if we abstract the state into a separate component that receiveschildren
, they won't re-render:The text was updated successfully, but these errors were encountered: