react-hooks Questions

2

Solved

I wonder if useMemo hook receives previous value for whatever it has memoized as any of the arguments to its callback?
Parent asked 27/3, 2019 at 8:38

3

I have two problems with the checkbox 1- When I click on each checkbox, they are correctly added to plantsFill, but duplicate items are also saved. I want it to be deleted if the plant_id is duplic...
Comfy asked 3/1, 2023 at 16:29

4

Solved

What is the case where you use useState's initial value as a function? Is there any difference from just passing a value? e.g. const [state, setState] = useState(() => someValue)
Grapevine asked 7/2, 2020 at 19:57

2

Solved

I'm trying to use the useContext hook to pass state and setState to a child component but I'm getting a ts error when I try and pass [state, setState] in the value argument of the provider. My code...
Nadabus asked 1/10, 2019 at 23:17

4

Solved

I have a search bar on my nav component. After each keystroke, the input loses focus and you have to re-click on it to type the next key. Here is the input: <input type="text" name="search" ...
Catalectic asked 5/12, 2019 at 16:49

2

Solved

I am using React.useRef inside a react functional component, I am getting an error message before i was using it inside a class component and now i have changed it to a react functional component a...
Symbolist asked 1/3, 2020 at 21:57

3

Solved

So I'm having a very weird issue with React Context + Typescript. Working example In the above example, you can see what I'm trying to do actually work. Essentially I'm managing state with the n...
Jenette asked 7/2, 2019 at 16:26

4

Solved

Datetime Picker is not opening i'm using react-native with react-hooks, in Android works fine . but its not opening in IOS and not showing any error. i just created local component for datepicker...
Unrestraint asked 3/2, 2020 at 7:16

2

Solved

How to cover the lazy load component in react testing library. import React, {lazy} from 'react'; const ownerInfo = lazy(() => import('../abc')) const compone = () => { return <Suspense&...

2

I'm testing a custom hook with react-testing-library which basically does this: function useHook() { const [state, setState] = useState(); const fetch = async () => { const response = await...
Streptomycin asked 11/2, 2022 at 17:27

4

Solved

Could not find any info on this that explains why its not generating and how to force it to re-generate these hooks. First I thought I had to run the app to get it to work so did yarn start. I ende...
Subroutine asked 8/10, 2021 at 23:7

3

How to use componentWillUpdate in functional component by react hooks ?
Sivan asked 16/11, 2019 at 13:6

4

Solved

I only want useEffect to run when my dependency list changes, it is also running every time the component is mounted, is there any way to not fire on mount? You can tell React to skip applying a...
Vickeyvicki asked 26/12, 2019 at 19:26

8

Solved

How to send http request on button click with react hooks? Or, for that matter, how to do any side effect on button click? What i see so far is to have something "indirect" like: export default =...
Coz asked 12/4, 2019 at 8:16

3

I'm trying to turn Material UI's dialog into a "useDialog" hook so it keeps track of it's own open state. Unfortunately I've encountered a problem that whenever I update a state further up the hie...
Rafaelita asked 13/6, 2020 at 16:59

3

Solved

I'd like to know how does React "freezes" the closure while using the useCallback hook (and with others as well), and then only updates variables used inside the hook when you pass them into the in...
Tripody asked 7/2, 2019 at 15:57

2

Solved

I want to establish a websocket connection with the server. Reconnect after 5 seconds if the connection closes. I am using React Hooks and so far achieved this import React, { useRef, useState, use...
Kuehn asked 7/7, 2020 at 5:13

23

Solved

With React 16.8.6 (it was good on previous version 16.8.3), I get this error when I attempt to prevent an infinite loop on a fetch request: ./src/components/BusinessesList.js Line 51: React Hook us...
Oleate asked 25/4, 2019 at 0:35

2

Solved

I am creating a reference using the new useRef hook const anchorEl = React.useRef<HTMLDivElement>(null) And using like <div style={{ width: "15%", ...flexer, justifyContent: &quo...
Posen asked 29/1, 2019 at 12:11

3

Solved

To restrict useEffect from running on the first render we can do: const isFirstRun = useRef(true); useEffect (() => { if (isFirstRun.current) { isFirstRun.current = false; return; } con...
Thud asked 28/7, 2019 at 10:54

36

I'm trying to use react hooks for a simple problem const [personState,setPersonState] = useState({ DefinedObject }); with following dependencies. "dependencies": { "react": "^16.8.6", "react-...
Creatural asked 25/4, 2019 at 10:0

5

Solved

My bestSellerDummy data doesn't change, so I'd like to prevent the same Product child to be rerendered if parent rerenders. I have tried using useMemo in parent and React.memo in child but no luck,...

5

Solved

I'm trying to use Antd Table https://ant.design/components/table/ with customized filters and React Hooks. Most of all code from provided example were converted to hooks' logic successfully but I ...
Duckett asked 11/5, 2020 at 19:46

3

Solved

I am confused about the differences between the useRef hook and a plain variable inside the component. Am I right that every component renders, the plain variable also re-renders and persists its v...
Enrique asked 25/11, 2022 at 11:26

2

Solved

I want to reuse a menu I made in react with react-router-dom, but this time in nextjs. The goal is to change the state of the menu to 'false' and the menuName to 'menu' when I click on a link insid...
Jair asked 25/1, 2021 at 12:9

© 2022 - 2024 — McMap. All rights reserved.