Top "React-hooks" questions

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

How test a component using the useReducer hook?

Reducer // src/reducers/FooReducer.js export function FooReducer(state, action) { switch (action.type) { case 'update': { return action.newState; } // ... other actions …

reactjs react-hooks enzyme react-hooks-testing-library
is it possible to React.useState(() => {}) in React?

is it possible to use a function as my React Component's state ? example code here: // typescript type OoopsFunction = () => void; …

reactjs typescript default-value react-hooks
How to use "useRouter()" from next.js in a class component?

I was trying to get the queries from my url pattern like localhost:3000/post?loc=100 by using useRouter() from "next/…

javascript reactjs routing react-hooks next.js
React useContext returns undefined

I'm trying to use React Context to manage states for my project, but I can't seem to make it work …

reactjs react-hooks react-context
React Component Not Updating After Changing A Value

In ReactJS, I'm writing a stateless component; Since I've read avoiding unnecessary states is best practice. The component represents an …

reactjs react-hooks react-state react-functional-component react-class-based-component
When to use native React.useReducer Hook and how it differentiate from Redux

So, Hooks are available from React 16.8. From their documentation, Hooks come as a replacer of state in functional components. The …

reactjs redux react-hooks
How to initialize the react functional component state from props

I'm using React hooks for app state, I wondered about how to initialize the functional component state using props? The …

reactjs initialization state react-hooks prop
Multiple times render in react functional component with hooks

Actually I am not getting the right point of this problem. So seeking help. I have this state full functional …

reactjs react-hooks use-effect
How to fix 'no fallback UI was specified' in react i18next using hooks

I am trying to implement i18next in my react component using the useTranslation hook, but it keeps saying: Uncaught …

reactjs react-hooks react-i18next react-suspense
Firebase listener with React Hooks

I am trying to figure out how to use a Firebase listener so that cloud firestore data is refreshed with …

javascript reactjs firebase google-cloud-firestore react-hooks