3 ms·
Are people just using "hooks" to mean "all new functionality in React that happens to be available to/as hooks"? To me it's like (actually very like) "oh we're
by karatestomp 6y ago
Are people just using "hooks" to mean "all new functionality in React that happens to be available to/as hooks"? To me it's like (actually very like) "oh we're doing that with methods". Uh. OK? Cool I guess? That's not informative.
- searchableguy 6y agoMaybe. I really don't know. There are some places where functionality is dependent on hooks. React fast refresh won't work with class components. (useState is the hook alternative to class style state management and fast refresh is fancy hot reloading but with persisted state and only reloading modified modules/components). There are few escape hatches only built as hooks mostly for improving performance issues which weren't previously available. But most of the hooks are basically reimplementation of features from class style components. There are differences in how hooks work though. Hooks are executed as they are laid out. Previous life cycle methods were dumped into a single useEffect hook. It's easy to change hooks and introduce separation in how you build your logic is what I assume they might be referring to. Instead of <Consumer> {({text}) => { return <div> {text} </div> }} </Consumer> You can do const [data] = useConsumer() return <div> {data.text} </div> It gets messy with a real complex application. typing on mobile is sad.
- hombre_fatal 6y agoIndenting by four spaces gives you preformatted text on HN. It's for code.
- jerrycruncher 6y agoYou're probably not far off. For the Redux case, that statement almost certainly means using at least one top-level Context Provider along with `useContext` in consuming components to replace or avoid the use of a Redux store and `connect`.