Top "React-hooks" questions

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

componentWillUnmount with React useEffect hook

How can the useEffect hook (or any other hook for that matter) be used to replicate componentWillUnmount? In a traditional …

javascript reactjs react-hooks react-lifecycle
How do I window removeEventListener using React useEffect

In React Hooks documents it is shown how to removeEventListener during the component's cleanup phase. https://reactjs.org/docs/hooks-reference.…

reactjs react-hooks removeeventlistener
React hook useEffect dependency array

I trying to wrap my head around the new hooks api of react. Specifically, I'm trying to construct the classic …

javascript reactjs react-hooks
Removing object from array using hooks (useState)

I have an array of objects. I need to add a function to remove an object from my array without …

reactjs typescript react-hooks
TypeError dispatcher.useState is not a function when using React Hooks

I have this component: import React, { useState, useEffect } from "react"; import ReactDOM from "react-dom"; function App() { const [count, setCount] = useState(0); …

javascript reactjs react-hooks
React Hooks: Why is .current null for useRef Hook?

I have a simple example of a component: function App() { const observed = useRef(null); console.log(observed.current); return ( <…

reactjs react-hooks
React-hooks. Can't perform a React state update on an unmounted component

I get this error: Can't perform a React state update on an unmounted component. This is a no-op, but it …

reactjs react-hooks
How to change Context value while using React Hook of useContext

Using the useContext hook with React 16.8+ works well. You can create a component, use the hook, and utilize the context …

javascript reactjs react-hooks react-context
How to focus something on next render with React Hooks

I'm playing with hooks, and I'm trying to do the following: import React, { useState, useRef } from 'react'; const EditableField = () => { …

reactjs react-hooks
componentDidMount equivalent on a React function/Hooks component?

Are there ways to simulate componentDidMount in React functional components via hooks?

javascript reactjs react-hooks