Skip to main content

All Questions

-3 votes
0 answers
41 views

How to make the setter function in react asynchronous [closed]

I have a situation, where I am rendering Rows inside another row, where the first row is an accordion. On click of the row, the API call happens and the resultant data is showed in the row inside So ...
Venkatesh 's user avatar
0 votes
2 answers
78 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, { ...
thulhid's user avatar
2 votes
1 answer
67 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 ...
user3146945's user avatar
-1 votes
0 answers
65 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 ...
Mir-Ismaili's user avatar
  • 17.4k
0 votes
0 answers
48 views

React Hooks (useState, useContext) not working when importing Vite-built redesign modules into CRA project

I'm working on updating a large React application ("webapp-front-end") by creating a new module-based redesign. The idea is to gradually migrate and refactor the UI using TypeScript. The new ...
Pedro Bernardes's user avatar
-1 votes
1 answer
50 views

How come visiting child component loses functionality?

I have an app that has a 3 JSX files: one for controlling states import React from "react"; import CreateRisk from "./CreateRisk"; import TablePage from "./TablePage"; ...
Aleks3000's user avatar
0 votes
1 answer
47 views

ReactJS : anonymous function accesses an old memo state

I'm learning ReactJS, and performance optimisation. I just stumbled on a case I just cannot explain. Below is the smallest code I could write showing the "issue" / strange behavior. I have ...
Jeremy's user avatar
  • 21
3 votes
1 answer
51 views

Why does consoling prints the same value but state gets updated when used inside useEffect - React

In a video I saw creating a progress bar and updated its value using state and wrapped it inside setInterval for updating it every 15 millisecond and the whole being wrapped inside useEffect, with no ...
ABISHEK NS's user avatar
1 vote
1 answer
43 views

Can't successfully test a custom hook using useState and useEffect

While learning React, I'm trying to understand custom hooks. I've created a simple one updating an internal "step" on creation, cleanup, and allows for external updates. But I'm struggling ...
Dgurio's user avatar
  • 13
1 vote
2 answers
153 views

I'm using React Router v7.20 and getting this error in my Account.jsx component [closed]

The error happens when I refresh the page or navigate between "/account", "/account/bookings", and "/account/places". import React, { useContext } from 'react'; import { ...
Ujjwal Gaihre's user avatar
-1 votes
1 answer
58 views

In useReducer, is it better to dispatch multiple actions separately for each state field or use a single action to update multiple fields at once? [closed]

In a React 17 useReducer setup, is it better to dispatch multiple actions separately, each updating a single state field, or to use a single action that updates multiple fields at once? For example, ...
Mohammad Noushad Siddiqi's user avatar
-3 votes
3 answers
116 views

Why there's infinite loop in useEffect hook? [closed]

index.jsx const { startTransition, useEffect, useState } = React; const { createRoot } = ReactDOM; function App() { const [foo, setFoo] = useState([1]); const [bar, setBar] = useState("1"); ...
pistol magic's user avatar
2 votes
0 answers
168 views

How Do I Preserve Selected Value in a React <select> Field After Form Submission Using useActionState?

I am working with a React form component, and I have a select field inside it. When the form is submitted, I want to preserve the selected value (the default value) in the select field. However, after ...
user29549047's user avatar
-1 votes
2 answers
70 views

useCallback on function passed to a leaf element in react? [closed]

If a component has a leaf element (like button) that takes an onClick function which is coming from a custom hook, should that onClick be wrapped in useCallback? Folder Structure - someComponent (...
Vedant's user avatar
  • 23
2 votes
3 answers
69 views

question related to use setInterval and useEffect, what's the difference between pass function name and anonymous function?

Recently I am reading article related to useInterval, these code works fine: import React, { useState, useEffect, useRef } from "react"; import ReactDOM from "react-dom"; function ...
Kelsey Zhou's user avatar

15 30 50 per page
1
2 3 4 5
1009