30,636 questions
-1
votes
0
answers
32
views
Can a useEffect await its own async cleanup function?
I have an async function that is being called in a useEffect. The cleanup cannot run until the function has returned, so it awaits the result. However, in StrictMode, the program runs twice, and the ...
0
votes
1
answer
66
views
Is there some useEffect and useState behavior that explains why only one of these instances work?
I'm using useEffect to fetch data. This data is passed to a state, then used as a prop for a component to render/populate accordingly. Here is the code that works:
const [projects, setProjects] = ...
-3
votes
1
answer
39
views
Which hook will render first in (UseState, UseEffect), in the React Component rendering [closed]
Today i am asking the question in ReactJS , that when the Component renders, and it has two Hooks, one is the useState, and the another is UseEffect(), can anyone tell me which hook will load first , ...
-4
votes
0
answers
24
views
Can anyone guide me to solve this (Django+React) webapp running problem [closed]
Something went wrong.
Details
TypeError: Cannot read properties of null (reading 'useState')
at Lt (http://localhost:3000/static/js/bundle.js:28766:11)
at div (<anonymous>)
at AuthProvider (http:...
1
vote
0
answers
37
views
Why the clean-up function of useEffect does not get the latest value of a state? [duplicate]
I have this section of code which will get the profile picture of a user and display it using createObjectURL and release the URL when i navigate away. The problem is that the avatarURL does not hold ...
0
votes
2
answers
80
views
Why is the second character missing and an undefined character added in my typing effect? [duplicate]
I'm working on a simple typing effect component in React using Framer Motion. Here's the code for my TypingText component
TypingText.jsx
import { motion } from 'framer-motion';
import React, { ...
-1
votes
1
answer
51
views
"React Hook useEffect has a missing dependency", but including it or removing the dependency array both make for incorrect behavior? [duplicate]
I am working on a React page that has a built in file manager.
I have a DocumentTable.js component, which is responsible for displaying the current list of files available, and it has (among others) ...
-3
votes
0
answers
51
views
How to use memoized value inside useEffect
I have a react functional component that does some initialization using useEffect() with no dependencies. I also have a memoized value and I want to use it in the initialization code to set some state ...
0
votes
2
answers
53
views
Apollo client cache not being reset after calling client.resetStore()
I am getting an unexpected behaviour. That is, I have put a skip condition in the query and even when the skip condition is supposed to be true, the query is being run. I have made a minimal ...
1
vote
1
answer
31
views
React Native useState rules
I have read that the rules for using React's hooks are:
Don’t call Hooks inside loops, conditions, or nested functions.
Instead, always use Hooks at the top level of your React function,
before any ...
2
votes
1
answer
72
views
I cannot figure out why ProtectedRoute wont re-render after updating useState
I would like the ProtectedRoute to call server and get a response that indicates whether the user is logged in or not, on every render of a page that it protects. The server is sent a session cookie ...
0
votes
1
answer
28
views
Remix (React) Waiting for Submit to complete without useMemo
I have a table where the last column is a button that triggers an action which in turn queries the DB, returns a result and downloads the result as a csv. In order for the data to be processed and the ...
-1
votes
0
answers
46
views
Potential solutions of issues surfaced by StrictMode in react and what should be the accepted approach [duplicate]
Consider a React API call flow example in a component:
When the component mounts, it triggers an API call inside useEffect.
Before the API call, I set a loading state to true.
After the API response ...
-1
votes
0
answers
66
views
ESLint rule to disallow useEffect without dependency list
Is there an ESLint rule for React to disallow writing useEffect without dependency list?
I'm looking for something like this:
useEffect(() => {
if (error) handleError(error)
}) // ❌ I expect ...
-1
votes
1
answer
71
views
Why is useEffect running in unexpected manner?
my route looks like this:
<Route path="game/:room_id" element={
<GameProvider>
<Game />
</GameProvider>
} />
Game.jsx(partial) ...