I am using two class components where I have a method that I am invoking from the parent component. and for this reason, I have to create two references using React.createRef()
. But the problem is one component allows me with ref
attribute and another innerRef
attribute. So I want to know what is the difference.
class X extends Component {
constructor(props) {
super(props);
this.xRef = React.createRef();
this.yRef = React.createRef();
}
render() {
return (
<Xcomponent
classes={classes}
user={user}
ref={this.xRef}
/>
<Ycomponent
classes={classes}
user={user}
innerRef={this.xRef}
/>
)
}
}