Hacker News new | ask | show | jobs
by searchableguy 2237 days ago
They might be using context. The problem with that though is it will cause performance issues due to unintentional rerendering. Not something to worry about for a small app.

https://reactjs.org/docs/context.html

1 comments

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.
Maybe. 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.

Indenting by four spaces gives you preformatted text on HN. It's for code.
You'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`.