3 ms·
Something that comes for free with Redux and its abstractions like Kea (the approach promoted in the linked blog post) is that you mostly avoid the problem of n
by mariusandra 5y ago
Something that comes for free with Redux and its abstractions like Kea (the approach promoted in the linked blog post) is that you mostly avoid the problem of needless re-renders.
Each `useSelector` call (and `useValues` call that uses it) triggers a re-render only when the value changed. So unless you have something forcefully re-rendering the root node, only the few relevant sub-sections of the page will re-render.
It's not perfect nested-sub-object level precision, but in practice works well enough.
- cutler 5y agoYet more useX to keep in your head. I don't get it with React.
- yakshaving_jgt 5y agoIt’s definitely easier to swap all of them for a simple useElm.
- mariusandra 5y agoIn the approach described in the blog post, you only need two use*: `useValues` and `useAction` to pull in values and actions from the data layer. Nothing else. No local state with `useState`, no `useEffect` or `useRef` or anything else for interacting with your data. So in effect React == two hooks and JSX.
- cutler 5y agoI was thinking more generally where idiomatic React makes use of the whole panoply of use* variants. React is unusable for me because of this. useForm alone has exploded recently into a proliferation of sub-variants then when you add useController into the mix it's game over.
- acemarke 5y agoIt seems like you're talking about the APIs for a specific library (React Hook Form) rather than React in general. Overall, hooks allow libraries to package custom behavior. The `useSelector` hook mentioned above is a React-Redux-specific API that manages subscribing to the store and re-rendering the component when the requested extracted state value changes. So, the "proliferation" you're talking about here is simply libraries and individuals building their own specific logic on top of React's primitives, in the same way that users build specific components on top of React's component primitives.
- cutler 5y agoIsn't React Hook Form ( https://react-hook-form.com/ https://react-hook-form.com/) from the React team?
- acemarke 5y agoNo. The React team doesn't work on _any_ official libraries except React itself. Brian Vaughn did create `react-virtualized` and `react-window`, but he maintains those separately from his status as a React team member. React Hook Form is from a community member named Bill-something, I think. Out of curiosity, what gave you the impression that RHF might be from the actual React team?