Top "React-hooks" questions

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

Wrong React hooks behaviour with event listener

I'm playing around with React hooks and faced a problem. It shows the wrong state when I'm trying to console …

javascript reactjs react-hooks
"Error: Too many re-renders. React limits the number of renders to prevent an infinite loop."

Hi I have been stuck in a React Function useState. I just want to learn hooks and useState, but I …

reactjs react-redux react-hooks
React Hooks with React Router v4 - how do I redirect to another route?

I have a simple react hooks application - a list of Todos - with react router v4 On the List …

javascript reactjs react-router react-router-v4 react-hooks
How to test a react component that is dependent on useContext hook?

I have a component that uses useContext and then its output is dependent on the value in the context. A …

reactjs jestjs react-hooks react-test-renderer
Where can I make API call with hooks in react?

Basically we do API calls in componentDidMount() life cycle method in React class components like below componentDidMount(){ //Here we do …

javascript reactjs react-native react-hooks
React createContext issue in Typescript?

So I'm having a very weird issue with React Context + Typescript. Working example In the above example, you can see …

reactjs typescript react-hooks react-context
What does useCallback/useMemo do in React?

As said in docs, useCallback Returns a memoized callback. Pass an inline callback and an array of inputs. useCallback will …

javascript reactjs react-hooks
Correct way to type nullable state when using React's useState hook

I am having trouble figuring out how to type useState function since it returns a tuple. In essence, I have …

reactjs typescript react-hooks
Set state when testing functional component with useState() hook

When I tested class component with enzyme I could do wrapper.setState({}) to set state. How can I do the …

reactjs enzyme setstate react-hooks
Is it possible to share states between components using the useState() hook in React?

I was experimenting with the new Hook feature in React. Considering I have the following two components (using React Hooks) …

javascript reactjs react-hooks