Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Two custom React hooks. Parent comment
From React's "Using the State Hook" docs:
> However, unlike this.setState in a class, updating a state variable always replaces it instead of merging it.
https://reactjs.org/docs/hooks-state.html#tip-using-multiple...
The `extendState` method gives you the same convenience of `this.setState` but with hooks in function components instead of class components.
I was replying to the poster who was using:
setState({...state, a: 4})
From React's "Using the State Hook" docs:
> However, unlike this.setState in a class, updating a state variable always replaces it instead of merging it.
https://reactjs.org/docs/hooks-state.html#tip-using-multiple...
The `extendState` method gives you the same convenience of `this.setState` but with hooks in function components instead of class components.