You can create a ref by calling React.createRef () and attaching a React element to it using the ref attribute on the element. class Example extends React.Component { constructor(props) { super(props) this. exampleRef = React.createRef() } render() { return (< div > < input type ="text" ref ={this. …

592

In 16.3 version of React has introduced a new API called React.createRef() for creating refs. We don't need to create a callback function and assign it to ref props here. So just create a ref and stored it into some variable and assign this variable to ref prop of DOM element.

You can also add different styles for all 3 buttons. it is useful when you want to access the DOM nodes or elements created in the render() method. Note: In this lesson, I will create Refs by the style of ReactJS,  Learn how to work with refs and portals to break free from your JSX cage and " https://unpkg.com/babel-standalone@6.15.0/babel.min.js" >.