react-hooks Questions

5

Solved

I am trying to build an app but the problem is when I change a state, all the components re-render. const App=()=>{ const [showMenu,setshowMenu]=useState(false) return( <> <Head...
Feathering asked 14/11, 2021 at 17:41

2

I'm trying to create a VS code user snippet for useState() Currently I have "use state": { "prefix": "us", "body": [ "const [$1, set${1/(.*)/${1:/up...
Unintelligent asked 2/10, 2019 at 23:14

2

Solved

I'm trying to learn about the hooks functionality, however I can't quite seem to figure out how I'm supposed to use the function useCallback properly. As far as I understand from the rules about ho...
Rattrap asked 5/3, 2019 at 15:18

4

Solved

How can I use a React ref as a mutable instance, with Typescript? The current property appears to be typed as read-only. I am using React + Typescript to develop a library that interacts with inpu...
Arrearage asked 19/9, 2019 at 18:40

3

Solved

CodeSandBox: https://codesandbox.io/embed/react-table-editable-content-ggvcy When attempting to handle input into React-table my input is losing focus so i can only type 1 character at a time. H...
Dorotheadorothee asked 8/8, 2019 at 19:4

6

Solved

I need to make a demonstration of using React Hooks useMemo. I have working code that is as follows that does what I want: const SpeakerCardDetail = React.memo( ({id,... I found a link that sho...
Mongo asked 2/4, 2019 at 2:28

7

Solved

Say I have a parent component with two child components: const Parent = () => { const [myVar, setmyVar] = useState(false) return ( <> <MyChildComponent1 myVar={myVar} setMyVar={se...
Pteropod asked 7/5, 2019 at 18:36

2

Solved

I'd like to change the props using react hooks, and I found the way passing setState function as props to the child. Container.tsx const Container: React.FC = () => { const [num, setNum] = us...
Harryharsh asked 10/12, 2019 at 6:48

8

Solved

See my code below. I'm trying to add this button that goes back to the previous page using react-router-dom but I get the below error, and also all the components on my website disappear. Error: u...

1

import { useState } from "react"; export default function App() { const [buttonClicked, setButtonClicked] = useState(false); console.log('Render'); return ( <div className=&quot...
Soundboard asked 14/7, 2023 at 20:26

11

Solved

We use a third party library (over which there is limited control) that takes a callback as argument to a function. What is the correct way to provide that callback with the latest state? In class ...
Upanchor asked 9/9, 2019 at 3:38

8

Unable to reach Expo servers. Falling back to using the cached dependency map (bundledNativeModules.json) from the package "expo" installed in your project.
Watery asked 3/8, 2022 at 9:55

23

Solved

I am writing code so that before the data is loaded from DB, it will show loading message, and then after it is loaded, render components with the loaded data. To do this, I am using both useState ...
Excited asked 10/3, 2020 at 13:40

3

I am using react as a frontend application, I want to export a portion of react component as pdf file using jsPdf. const handleDownload = () => { const content = document.getElementById('downlo...
Bowyer asked 4/3, 2022 at 9:39

7

Solved

I want to save state to localStorage when a component is unmounted. This used to work in componentWillUnmount. I tried to do the same with the useEffect hook, but it seems state is not correct in ...
Thenceforth asked 5/12, 2018 at 13:40

5

Solved

I have two buttons, one of type "button" and one of type "submit", both wrapped in a form and which toggle each other. Weirdly, if I click on the button of type "button&quo...
Elver asked 3/7, 2023 at 2:47

2

Solved

I'm trying to build a markdown previewer using react and the marked node package. Everything works up to when I try to parse any markdown on the DOM. When I do I get an error message: Uncaught Type...
Citadel asked 9/1, 2022 at 21:55

4

I'm currently thinking about the perfect architecture for my professionals projects needs. I read a lot of article about (clean) architecture and I got to the point were I think that I want my UI m...
Jeannettajeannette asked 18/3, 2022 at 10:19

2

the useState hooks are great. I mainly use the useState hooks to initialise certain states, and I also pass the function to children components to change the states. However, I realise I am startin...
Superable asked 1/7, 2020 at 16:46

9

I'm trying to wrap my head around custom hooks. I understand normal hooks which is just fine, but my question is, when writing a custom hook, what is the difference between that and a normal functi...
Fairyfairyland asked 9/2, 2020 at 4:20

1

Is this an accurate polyfill of react's upcoming useEffectEvent hook? Does it present any potential issues? One part I was not sure about was whether the ref is guaranteed to have been updated prio...
Collaborate asked 25/5, 2023 at 18:17

5

Solved

Good day, so I am trying to perform an intermediate function before a form action="POST" takes place. Ive tried two things firstly onSubmit={functionName} but the form always performs the...
Orthocephalic asked 21/7, 2020 at 13:47

2

Solved

I have been working on adjusting iframe height automatically. The solutions with the problem are not working in React Hooks. I have read Setting iframe height to scrollHeight in ReactJS and Adjust ...
Provincetown asked 22/4, 2021 at 17:39

3

Solved

I'm writing some jest-enzyme tests for a simple React app using Typescript and the new React hooks. However, I can't seem to properly simulate the api call being made inside the useEffect hook. ...
Eel asked 28/3, 2019 at 0:48

4

I have a react application which uses react-redux, useSelector to get data from the store. The react component has function PersonDataView() { const name= useSelector(state => state.data.nam...
Roughen asked 31/1, 2020 at 21:29

© 2022 - 2024 — McMap. All rights reserved.