Class components and migration

createRef

Creates a new ref object; a class typically creates it once in an instance field and attaches it to a DOM element.

Formal Syntax & Structure

react syntaxreact
input = React.createRef();

Working Example

Example Snippetreact
class Search extends React.Component { input = React.createRef(); render(){ return <input ref={this.input}/>; } }
React Reference