Questions tagged [create-ref]
28 questions
0
votes
1 answer
passing ref from parent functional component to child class component to call a function in child class component
I have a parent functonal component:
const parentFunc = () => {
if (ref.current) {
ref.current.getKinList();
}
};
{parentFunc()}
>
click

pratteek shaurya
- 850
- 2
- 12
- 34
0
votes
1 answer
react createref was returning the error due to wrong implementation
This is the edited question after submitting the answer
In this code, my file browser will now directly open but when I am submiting the final button then I am not getting the updated state.
uploadImage() will be converting the image to base 64 and…

Aks
- 1,092
- 3
- 12
- 29
0
votes
1 answer
can't use react ref to dynamically set distance
github: https://github.com/Brent-W-Anderson/shoe_store/tree/main
Hi, I need help using my react ref correctly. I'm creating an image slider and I'm centering the first image in the set based on the image width (which is based on a height all of the…

Brent Anderson
- 71
- 1
- 7
0
votes
0 answers
React createRef not working with Redux. childRef.current always returns null
After a lot of googling, I can't find a solution. I need to call a child function from the parent component. Both are class components.
Some code
constructor(props) {
super(props)
this.childRef = React.createRef();
…

redmaster
- 95
- 1
- 12
0
votes
0 answers
Custom TextInput component with Ref's in react-native
I have a problem in react-native.
my application has many screens and forms.
I need to create TextInput component for this style and keep the program in clean code.
this is my TextInput component:
import React, { Component } from 'react';
import {…

fatemeh kazemi
- 516
- 6
- 10
0
votes
1 answer
ScrollIntoView() can find the html element
I'm trying to create a scroll to element but I'm getting this error
"TypeError: Cannot read property 'scrollIntoView' of null".
By console logging mapRef I can see that I'm getting the correct div.
console.log
export class FinderComponent extends…

Jānis Kļaviņš
- 17
- 4
0
votes
1 answer
How can I clear the the inner text of a ref.current value, in React?
How can I access the inner text value property of a ref.current.
By console.log(loginField.current) I got:
The way…

Rafael
- 2,413
- 4
- 32
- 54
0
votes
1 answer
Why i can't access my two container's current target value using react js on making outside click?
Using this https://codedaily.io/tutorials/Create-a-Dropdown-in-React-that-Closes-When-the-Body-is-Clicked i have found my solution to make my dropdown to get close on click of outside anywhere else.
But problem is, i have two similar components of…

Mercy Kannan
- 1
- 3
0
votes
0 answers
React Bootstrap Typeahead getInstance() not a function
I have two instances of AsyncTypeahead being rendered in a component by a separate class.
In order to keep the blur function tied to the right field I'm using .getInstance().
So in my constructor I'm using:
this.typeahead =…

Best Dev Tutorials
- 452
- 2
- 6
- 22
0
votes
1 answer
react-day-picker ref current scrollIntoView not accessible
I am using react-day-picker. I want to scroll into "calendar" - DayPicker Component after i click into input (problem is when page is scrolled, then calendar is not in viewport. I tried this approach (simplified):
import React from 'react';
import…

Martin Fric
- 726
- 2
- 9
- 27
0
votes
1 answer
reactjs createRef not work in component arrays
like this i hava a array of components need ref to trigger the comment component collapse, so i need to create some refs to reference each commentListItem, but it doesn't work, how do i do this work?
import React, { useRef, createRef } from…

TiglathPileser
- 53
- 1
- 8
0
votes
1 answer
Property 'checked' does not exist on type 'Switch'
I am getting a Property 'checked' does not exist on type 'Switch'. message from TypeScript for this.checked and this.disabled createRefs. Also, on the last line, I am also getting a Property 'checked' does not exist on type 'Switch warning from TS.…

Eddie Lam
- 579
- 1
- 5
- 22
0
votes
1 answer
Handling Ref in React Functional Component written in TypeScript: Element is not assignable error
I am running into possibly a syntax problem with my following code. elementRef as updated towards the bottom of the code in a div with the ref attr, linting is telling me:
let elementRef: React.MutableRefObject
Type 'HTMLDivElement | null' is…

bort
- 310
- 1
- 2
- 13