class Input extends Component {
        constructor() {
          super()
          this.myInput = React.createRef<HTMLInputElement>(null)
        }
        render() {
          return (
            <input ref={this.myInput} type='text' />
        	)
      	}
      }
      
      Typescript language logo

      React input with reference

      Codiga's TypeScript Recipes

      Create input and use React.createRef API to set up a reference by initializing it as null and declaring the HTML type

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.