Mode 1: String binding

Similar to the ref binding in VUE, this. Refs. The name of the bound ref gets the node DOM. Note that this method is not recommended in the latest react release and may be abandoned in future releases

Method 2: the react. CreateRef ()

By creating variables in the class using the react.createref () method, you can bind these variables to the ref of the tag so that the current of the variable points to the bound tag DOM

Method 3: Functional form

Declare a function in a class and bind ref to the function using this method to expose the child to the parent so that the parent can call the child’s methods

The entire child component can be exposed to the parent component by binding the ref to the method of the function

Note: React does not recommend overusing refs. If you can do something with state, you should not use refs to “make things happen” in your app. Overuse of refs is not consistent with data-driven thinking