Answer the question
In order to leave comments, you need to log in
Why is createRef needed in class components?
Why is it needed React.createRef()
in class components?
What is the essential difference between:
class MyComponent extends React.Component {
myRef = null
render() {
return <div ref={ref => myRef = ref} />;
}
}
class MyComponent extends React.Component {
myRef = React.createRef();
render() {
return <div ref={myRef} />;
}
}
Answer the question
In order to leave comments, you need to log in
Reading the documentation - https://ru.reactjs.org/docs/react-api.html#reactcr...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question