react-hooks Questions

3

I am developing a React hook based functional application with TypeScript and I am using modal from ant design. I'm submitting a form through modal for a table. So, the modal will be called for mor...
Rhineland asked 7/9, 2020 at 12:13

7

Solved

I've tried using the "reset" function form react-hook-form but after submitting the input fields are not emptying. I don't know why exactly, I"m sure I"m missing something but c...
Cupriferous asked 23/7, 2020 at 15:39

9

Solved

I have just began playing around with React hooks and am wondering how an AJAX request should look? I have tried many attempts, but am unable to get it to work, and also don't really know the best...
Peso asked 30/10, 2018 at 7:9

3

Solved

As you can see in my example const rootElement = document.getElementById("root"); ReactDOM.render(<App />, rootElement); function App() { const items = ["this", "that", "those", "t...
Esplanade asked 18/2, 2020 at 21:21

3

Solved

What is the difference between useMutationEffect and useLayoutEffect in term of usage? I have read all available material online including (but not limited to) Hooks Reference Blog post by Kent ...
Zumwalt asked 28/11, 2018 at 7:3

3

const res = { results: { documents: [ { suggestion: 'tes1', }, { suggestion: 'test2', }, { suggestion: 'test3', }, { suggestion: 'test4', }, ], }, meta: { request_id: '0e6aa4da',...
Cistaceous asked 15/3, 2022 at 14:14

4

Solved

"react-router-dom": "^6.0.0-alpha.5", I have tried nearly everything. I just want to mock this navigate() call from the useNavigate() hook. that's it. Simple. Nothing working. ...
Fraya asked 19/2, 2021 at 20:3

2

const useSomeHook = ({number}) => { const [newNumber, setNewNumber] = useState(0) useEffect(() => { setNewNumber(number + 1) }, [number]) } const SomeComponent = ({number, value, ...res...
Earn asked 26/4, 2020 at 9:28

1

So I use react-query to handle API requests. Current problem is that when i try to submit form data, post request, mutation state is always idle, and loading is always false. I also use zustand for...

8

I looking for a solution about get an array of DOM elements with react useRef() hook. example: const Component = () => { // In `items`, I would like to get an array of DOM element let ite...
Discriminating asked 1/3, 2019 at 8:8

1

Most <input> elements use a value prop to set the value, and so they can be externally controlled by a parent. However <input type='file'> sets its value from a files attribute, and I'm...
Brander asked 25/4, 2023 at 16:1

2

Solved

I'm trying out the new React Hooks's useEffect API and it seems to keep running forever, in an infinite loop! I only want the callback in useEffect to run once. Here's my code for reference: Click...
Marnimarnia asked 10/11, 2018 at 20:40

5

I'm in the process of refactoring some of our components so I'm trying to incorporate memoization as some components may re-render with the same values (for example, hotlinked image URLs unless the...
Nika asked 27/5, 2020 at 11:22

6

I want to implement multiple checkboxes on my HTML page using react-hook. I tried implementing using this URL: https://medium.com/@Zh0uzi/my-concerns-with-react-hooks-6afda0acc672. In the provided...
Manhattan asked 23/5, 2019 at 10:16

3

Solved

In the docs it says that we should only call hooks at the top level of our components. Due to the API of useEffect, return is already reserved for the cleanup which made me wonder how I could early...
Christiano asked 10/2, 2019 at 10:49

4

Solved

I am using VSCode, and when I add the line 'react-hooks/exhaustive-deps': 'warn' to my .eslintrc.js, I get the following in the ESLint output: Rules with suggestions must set the `meta.hasSuggestio...
Liverwort asked 15/10, 2021 at 0:23

4

Solved

useReducer is usually preferable to useState when you have complex state logic that involves multiple sub-values or when the next state depends on the previous one. useReducer also lets you optim...
Saguaro asked 12/2, 2019 at 9:19

5

I am creating a react wizard component, and want to pass data נetween parent and children using contextץ So I created a wizard, context, provider, and custom hook, but the issue is that if I try t...
Perfective asked 29/9, 2019 at 6:22

3

Solved

I have a parent functional component <EditCard/> that is a modal opened when the edit table row button is selected. This edit card contains a state variable called data which consists of the ...
Relish asked 25/9, 2019 at 21:20

9

Solved

I have this specific need to listen to a custom event in the browser and from there, I have a button that will open a popup window. I'm currently using React Portal to open this other window (Popup...
Psalter asked 3/12, 2018 at 14:34

9

Solved

I have this component: import React, { useState, useEffect } from "react"; import ReactDOM from "react-dom"; function App() { const [count, setCount] = useState(0); useEffect(() => { docume...
Nazar asked 27/10, 2018 at 17:3

6

Solved

I was going through the hooks documentation when I stumbled upon useRef. Looking at their example… function TextInputWithFocusButton() { const inputEl = useRef(null); const onButtonClick = () =...
Illyria asked 10/2, 2019 at 20:27

5

Solved

Here is my form looks like and also CodeSanbox. currently I'm using react-hook-form as you can see form has 3 inputs. Submit button should be disabled until all the required fields are entered. Tw...
Umbel asked 11/12, 2020 at 19:54

5

Solved

How can I use react hooks and get query string value? with react class I use : const id = this.props.match.params.id;
Chiliarch asked 17/6, 2020 at 10:36

5

I am trying to create a replacement of useState in next.js resilient to page refreshes. One of the possible solutions that came across was to use window.localStorage to save and retrieve the state....
Despair asked 13/7, 2022 at 6:9

© 2022 - 2024 — McMap. All rights reserved.