Top "React-hooks" questions

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

React Native: Passing props between components and componentWillMount() method

I'm using React Native 0.43. I've two components, named ParentComponent and ChildComponent. I want to pass some props from parent to …

reactjs react-native react-hooks prop
Why is the cleanup function from `useEffect` called on every render?

I've been learning React and I read that the function returned from useEffect is meant to do cleanup and React …

javascript reactjs react-hooks use-effect
How can I prevent my functional component from re-rendering with React memo or React hooks?

When hiddenLogo changes value, the component is re-rendered. I want this component to never re-render, even if its props change. …

javascript reactjs ecmascript-6 react-hooks
React Error Boundaries not working with React

This is my Error Boundary file - class ErrorHandling extends Component { state = { hasError: false } componentDidCatch() { this.setState({ hasError: true }) } render() { // …

javascript reactjs react-hooks react-error-boundary
Testing React components that fetches data using Hooks

My React-application has a component that fetches data to display from a remote server. In the pre-hooks era, componentDidMount() was …

reactjs jestjs enzyme react-hooks react-test-renderer
React hooks useEffect only on update?

If we want to restrict useEffect to run only when the component mounts, we can add second parameter of useEffect …

reactjs react-hooks
React hook useEffect runs continuously forever/infinite loop

I'm trying out the new React Hooks's useEffect API and it seems to keep running forever, in an infinite loop! …

javascript reactjs react-hooks
How should I test React Hook "useEffect" making an api call with Typescript?

I'm writing some jest-enzyme tests for a simple React app using Typescript and the new React hooks. However, I can't …

typescript jestjs axios enzyme react-hooks
react-hooks: skip first run in useEffect

How I can skip first run in useEffect hook. useEffect(() => { const first = // ??? if (first) { // skip } else { // run main code } }, […

reactjs react-hooks
How to use shouldComponentUpdate with React Hooks?

I've been reading these links: https://reactjs.org/docs/hooks-faq.html#how-do-i-implement-shouldcomponentupdate https://reactjs.org/blog/2018/10/23/react-v-16-6.html In …

javascript reactjs functional-programming react-hooks