react-hooks Questions
5
Solved
I gather that the useEffect Hook is run after every render, if provided with an empty dependency array:
useEffect(() => {
performSideEffect();
}, []);
But what's the difference between that,...
Teammate asked 27/10, 2019 at 12:28
3
Solved
As per title, what I'm trying to achieve is to display the Wysiwyg content from the Editor to another component.
I created a sample on codesandbox here: https://codesandbox.io/s/boring-tharp-zwflu...
Anhydrous asked 25/5, 2020 at 12:3
10
Solved
I am following a Udemy course on how to register events with hooks, the instructor gave the below code:
const [userText, setUserText] = useState('');
const handleUserKeyPress = event => {
c...
Prithee asked 8/4, 2019 at 2:19
2
Solved
I'm using hooks for updating state. in my code I have an AppState event listener and whenever it triggers I'm updating the appState using setAppState, however the appState inside the event listener...
Succory asked 7/7, 2020 at 10:3
3
Solved
I'm new to React Hooks. I have a UI with multiple inputs with values in an object. I create the UI with a loop, so I would like to have a single callback for the updating the inputs.
The "Sho...
Penurious asked 29/3, 2020 at 7:9
3
Solved
I followed the ReactJS documentation regarding the useState hook but I cannot get it to work with radio buttons. It doesn't select any radio button at all.
By the way I am using react-semantic ui f...
Arlinearlington asked 25/9, 2019 at 8:39
3
I have this error:
src/index.js Line 9:36: The object passed as the value prop to the
Context provider (at line 9) changes every render. To fix this
consider wrapping it in a useMemo hook
react/js...
Olav asked 23/2, 2022 at 8:7
4
Solved
I have a problem with useRef in TypeScript.
I want to type it but I get an error, like this:
My Container component is:
const HeaderContainer: React.FC = () => {
const addressElement = useRef...
Hengist asked 27/11, 2020 at 14:0
5
I'm trying not to lose my state value which is cart when the page is reloaded. I can add any productto my cartat any page but whenever i reload the page cartstate resets itself. Is there anyway to ...
Shitty asked 10/12, 2020 at 9:7
17
Solved
Let's say I have 3 inputs: rate, sendAmount, and receiveAmount. I put that 3 inputs on useEffect diffing params. The rules are:
If sendAmount changed, I calculate receiveAmount = sendAmount * rat...
Fortna asked 23/11, 2018 at 11:40
8
Solved
There's some data coming from long polling every 5 seconds and I would like my component to dispatch an action every time one item of an array (or the array length itself) changes.
How do I prevent...
Seldon asked 24/12, 2019 at 10:58
3
Solved
I have two components: App and Child. I use useRef hook to get the DOM element in Child component and do some work with it.
I also pass ref from App component to Child component using React.forward...
Lajoie asked 28/6, 2021 at 11:32
12
Solved
Let me explain the result of this code for asking my issue easily.
const ForExample = () => {
const [name, setName] = useState('');
const [username, setUsername] = useState('');
useEffect((...
Hyden asked 6/3, 2019 at 9:49
3
Solved
Can someone please give the solution to this warning message?
137:7 warning The 'slider1' array makes the dependencies of useEffect Hook (at line 143) change on every render. To fix this, wrap the...
Floppy asked 14/10, 2021 at 14:37
19
Solved
When fetching data I'm getting: Can't perform a React state update on an unmounted component. The app still works, but react is suggesting I might be causing a memory leak.
This is a no-op, but it...
Venola asked 2/3, 2019 at 1:25
4
Here is my custom hook:
export function useClientRect() {
const [scrollH, setScrollH] = useState(0);
const [clientH, setClientH] = useState(0);
const ref = useCallback(node => {
if (node !...
Plemmons asked 17/2, 2020 at 20:34
3
Solved
I am new to React hooks and I am not sure how to achieve following goal. Let's say I have state1 and state2, and I use useEffect hook to call asyncFn1 and update state1.
Now I want to wait for stat...
Berardo asked 25/4, 2021 at 7:1
2
Solved
I'm trying to create a React app with a single p5.js sketch. However, the component containing the p5 sketch is being duplicated on my page. Not sure why it would be rendered this way.
Here you can...
Ratty asked 23/5, 2022 at 13:27
5
I'm trying to use the HTML <details> tag to create a simple expandable section using semantic html in combination with React.
The <details><summary></summary></details&...
Whopping asked 19/11, 2019 at 20:50
5
A page displays a list of objects [{name:, age:}, ...]
A second page allows to update the name of a particular object.
Then using hooks, how should I implement useEffect() so the list on the front ...
Fronniah asked 6/5, 2019 at 18:26
11
Solved
I have a react app. There is a checkbox which disables the datepicker. But I can't select any date when I'm using checkbox to disable it. If I remove checkbox and its function there is no error. Cu...
Klondike asked 25/10, 2020 at 19:19
5
Solved
As said in docs, useCallback
Returns a memoized callback.
Pass an inline callback and an array of inputs. useCallback will return a memoized version of the callback that only changes if one of the ...
Overton asked 5/11, 2018 at 17:27
4
Solved
I have some difficulties to understand the new way to use react Context API.
I have an app with a custom class Firebase. Now I want to make a hook to pass it. Before I used HOC (higher-order Compon...
Tyrocidine asked 19/2, 2019 at 4:14
0
Is it possible to spy for the #hash in Next.js 13v apps?
What do I do wrong? Its seems like 'hashchange' event just doesn't work an anaught - only for the first app render.
Now I'm trying to do thi...
Tetravalent asked 4/8, 2023 at 23:3
11
Solved
With React's new Effect Hooks, I can tell React to skip applying an effect if certain values haven't changed between re-renders - Example from React's docs:
useEffect(() => {
document.title = ...
Savaii asked 6/11, 2018 at 19:54
© 2022 - 2024 — McMap. All rights reserved.