Answer the question
In order to leave comments, you need to log in
How to get ref only when element is first created by key?
As the doc says , when updating the element tree, ref will be called first with null and then with the same HTMLElement.
Assuming neither the key nor the HTMLElement has changed, I don't need ref to be called.
Is there a built-in ability to get only modified refs?
Answer the question
In order to leave comments, you need to log in
It says not at all about this, but that it is not necessary to write inline functions in ref.
Not right:
class Example extends React.Component {
ref;
render() {
return <div ref={node => this.ref = node} />;
}
}
class Example extends React.Component {
ref;
createRef = node => this.ref = node;
render() {
return <div ref={this.createRef} />;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question