Top "React-hooks" questions

Hooks is a new feature that allows developers to use state(s) and other React features without writing a class.

Infinite loop in useEffect

I've been playing around with the new hook system in React 16.7-alpha and get stuck in an infinite loop in …

reactjs react-hooks
Handle an input with React hooks

I found that there are several ways to handle user's text input with hooks. What is more preferable or proper …

reactjs react-hooks
Updating and merging state object using React useState() hook

I'm finding these two pieces of the React Hooks docs a little confusing. Which one is the best practice for …

javascript reactjs react-hooks
How to programmatically clear/reset React-Select?

ReactSelect V2 and V3 seems to have several props like clearValue, resetValue and setValue. Whatever I'm trying, I'm not able …

javascript reactjs functional-programming react-hooks react-select
Is useState synchronous?

In the past, we've been explicitly warned that calling setState({myProperty}) is asynchronous, and the value of this.state.myProperty …

javascript reactjs react-hooks
Executing async code on update of state with react-hooks

I have something like: const [loading, setLoading] = useState(false); ... setLoading(true); doSomething(); // <--- when here, loading is still false. …

javascript reactjs callback react-hooks
React Hook : Send data from child to parent component

I'm looking for the easiest solution to pass data from a child component to his parent. I've heard about using …

reactjs react-hooks
Make React useEffect hook not run on initial render

According to the docs: componentDidUpdate() is invoked immediately after updating occurs. This method is not called for the initial render. …

javascript reactjs react-hooks
With useEffect, how can I skip applying an effect upon the initial render?

With React's new Effect Hooks, I can tell React to skip applying an effect if certain values haven't changed between …

reactjs react-hooks
How do I update states onchange in an array of object in React Hooks

I have retrieved datas stored using useState in an array of object, the datas was then outputted into form fields. …

javascript reactjs react-hooks