react-ref Questions
6
Consider I have a custom hook that uses one or more refs to DOM elements, I see two distinct ways how to write/use a hook like that (and I know there are probably even more nuances – e. g. ca...
Ber asked 13/3, 2021 at 15:52
4
Solved
I'm working on something in react and have encountered a challenge I'm not being able to solve myself. I've searched here and others places and I found topics with similar titles but didn't have an...
Shrum asked 26/5, 2021 at 5:5
3
Solved
I'm not using typescript in my reactjs project, but I still want to document my components with JSDocs.
The problem where is that I have a functional component with React.forwardRef and I want to c...
Saddletree asked 31/7, 2020 at 17:33
3
Why can't you pass a ref to a functional component in react?
What is different in function components compared to class components that you can't pass a ref to it?
Why is that not possible?
Notes: ...
2
Solved
I am trying to create a component that will track the vertical scroll. The catch is – the actual scroll container is not easily predictable (in this specific case it is neither window, document nor...
Saransarangi asked 12/1, 2022 at 14:20
3
I'm struggling to understand why the typescript compiler is unhappy with the forwardRef I'm using in a component.
I've pared my code right down to the bare essentials for the example below, ensurin...
Madeira asked 21/5, 2021 at 14:13
2
I am creating a component that will hold a dynamic list of elements and for styling reasons, I need to keep the title for each section in a sticky nav menu.
As the user scrolls up and down the list...
Turino asked 29/3, 2022 at 18:53
5
Solved
I'm having a lot of trouble scrolling to the top of my Flatlist so any help would be greatly appreciated!
Essentially it fetches the first 5 items from firebase, then when onEndReached is called w...
Soekarno asked 20/5, 2018 at 15:50
2
Question:
I have a React functional component that recursively renders nested lists. That part is working fine.
The part that I am struggling with is getting the divs that contain the nested lists ...
Corruption asked 12/9, 2019 at 2:49
1
The correct way of passing refs to child components as per react documentation is like this:
import React from 'react';
const Input = React.forwardRef((props, ref) => {
React.useEffect((...
Quartet asked 29/11, 2021 at 5:32
1
Here is an example of a mutable ref storing the current callback from the Overreacted blog:
function useInterval(callback, delay) {
const savedCallback = useRef();
// update ref before 2nd effec...
Blankbook asked 25/5, 2020 at 9:45
3
Solved
I'm trying to create a generic text input component for our application using react and typescript. I want it to be able to either be an input element or a textarea element based on a given prop. S...
Saideman asked 18/9, 2020 at 23:17
2
I am getting the following error but I am not able to figure out how to fix it someone can help me out.
Below is also the link on expo with the complete code.
Error on <AppIntroSlider /> whic...
Syrup asked 5/12, 2020 at 18:52
1
Solved
I am learning how to use forward refs here I have a FC where I need to initalize all my refs and then pass them down to it's children so I can get the canvas instances of some chartjs charts. Howev...
Trondheim asked 16/9, 2020 at 19:44
1
How would you go about storing Ref elements in Redux and would you do it at all?
I have a component containing some form elements where I need to store the state of which field in the form the user...
Mungovan asked 9/8, 2020 at 10:43
2
Solved
"react": "^16.13.1"
"react-transition-group": "^4.3.0"
<React.StrictMode>
<Router>
<App />
</Router>
</React.StrictMode>
Hi, everyone.
I faced with findDOMNod...
Ostracon asked 31/3, 2020 at 9:0
3
Solved
const Comp1 = forwardRef((props, ref) => {
useImperativeHandle(ref, () => ({
print: () => {
console.log('comp1')
}
}), []);
return <div>comp1</div>
});
const Comp2 = () ...
Impiety asked 16/10, 2019 at 11:1
2
Solved
I have a table list where each row has a menu button, for which I need a ref. I am using react mui in my project and it's menu. I have tried creating the refs like this:
const {rows} = props;
cons...
Hagio asked 12/9, 2019 at 7:27
2
Solved
I am trying to figure out how I need to use React.createRef() in react native with typescript as following code throws errors
// ...
circleRef = React.createRef();
componentDidMount() {
this...
Octangle asked 12/10, 2018 at 8:54
2
Normally, with props, we can write
componentDidUpdate(oldProps) {
if (oldProps.foo !== this.props.foo) {
console.log('foo prop changed')
}
}
in order to detect prop changes.
But if we use Re...
Dietitian asked 24/4, 2019 at 20:49
1
Solved
I am using refs for access child component
<MyComponent
ref='_my_refs'
...
/>
and call them
this.refs._my_refs.scrollToTop();
I get the error below
Warning: Function components can...
Vorlage asked 28/1, 2020 at 12:17
6
Solved
I have an element with a ref that is defined and ends up getting rendered into the page :
<div ref="russian" ...>
...
</div>
I want to access the DOM element properties like offse...
Anacoluthia asked 5/2, 2016 at 17:26
0
this is a question about using React refs inside of specs. specifically, I am seeing different behavior in my browser from what I see when run in the test.
// app_container.test.js
import React...
Transfiguration asked 11/12, 2019 at 20:38
1
Solved
I have two components. A parent and a child.
Inside the parent component I have a button. If the user clicks on that button I want to do a ScrollIntoView to another button inside the child componen...
Druce asked 2/12, 2019 at 15:40
2
Solved
Please refer to this URL in the React DOCS. A version of this code is also available here.
I understand that inside a Functional React Component, it is preferred to use the useCallback hook to cre...
Bria asked 27/9, 2019 at 1:24
1 Next >
© 2022 - 2024 — McMap. All rights reserved.