288 questions
0
votes
0
answers
41
views
ul ref not getting updated when a list element is removed and as such the focus goes back to the body
I have an unordered list wherein each list item is a card which contains a button. The button opens a popover with 2 options - edit/delete.
When I tab through to the button and click on delete, a new ...
3
votes
2
answers
256
views
In React, why does useRef need .current but useState doesn't?
Ref interface:
// create
const count = useRef(0);
// update (does not trigger render)
count.current = 5;
// access
console.log(count.current);
State variable interface:
//create
const [count, ...
0
votes
1
answer
138
views
useEffect not running when ref.current is removed from dependency array in React
I'm using a DynamicForm component with a ref in a React functional component. I want to update the form once my Firebase collection is loaded. Here’s the relevant part of my component:
const ...
0
votes
2
answers
112
views
How to manually set focus on a button with refs for Keyboard Accessibility?
I have a webpage where users have a list of images they've uploaded. They have three buttons: Upload Image/Download Image/Delete Image. When the user clicks Delete, the Upload button will hide and ...
1
vote
1
answer
38
views
Why is my fileRef not opening the element I'm referencing onClick
I want to upload a file by clicking the image element.
I have an Input element of file type with a useRef. I'm referencing the useRef in the img Onclick but it's not opening the file selector.
I ...
1
vote
2
answers
61
views
How to create a vector of references and pass it to children components?
I have a parent component which uses N children components, where N depends on the props in input. For example:
function Parent({ cards }: { cards: Cards[] }) {
return (
<>
{cards....
4
votes
2
answers
186
views
How to efficiently reuse AllHTMLAttributes interface across multiple components in React 19 with TypeScript?
I've been using React 19, and with the changes to how ref is handled, I noticed I need to adjust my code for components that inherit standard HTML element attributes.
Previously, I used forwardRef ...
5
votes
2
answers
5k
views
dialog causes error Accessing element.ref was removed in React 19
I'm using primereact with nextjs but i get error Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.. so i guess ...
0
votes
1
answer
39
views
React(Next.js) useRef question with video (npm run build vs npm run dev)
I can't figure out how to prevent the playerRef from reloading when clipLink change.
When i work on dev mode(npm run dev), i can switch videos without reloading playerRef. However, when i work on ...
-2
votes
2
answers
261
views
What's the difference between creating a ref without useRef vs. with useRef in React? [duplicate]
I've been working with React, and I'm trying to understand the difference between creating a reference using useRef and creating a reference without it. I've implemented two versions of a simple ...
-1
votes
1
answer
86
views
Forwarded ref is empty
I have the following forwarded ref in React:
export type AccordionHeaderProps<T extends ElementType> = {
children: React.ReactNode;
asTrigger?: boolean;
subTitle?: React.ReactNode;
...
0
votes
3
answers
108
views
Ref to html element does not have correct height
I know this has been asked many times and the answer is always that the effect does not run when refs are mutated but that is not the issue because I run the effect every second until I have an html ...
0
votes
1
answer
394
views
how to fix function component cannot be given refs while using framer motion useAnimate hook?
Navbar component code
import Humburger from "./ui/Humburger";
const navlins = ["HOME", "PAGES", "PRODUCTS", "ARTICLES", "CONTACT"];
const ...
3
votes
2
answers
686
views
the clean up function of the Ref callback is not executed
Here in my React the clean up function is not executed when re-rendering:
import React, { useRef, useState } from 'react';
export default function App() {
const [x, setX] = useState(2);
const d = ...
0
votes
2
answers
121
views
React Component Collapsing Issue: Ref Not Initialized During URL Parsing
I have a component that should expand if it is selected. Here's my current approach:
<Element
ref={elementRef}
style={{ height: isSelected ? `${elementRef.current.scrollHeight}px` : '0px' }} ...