React input with reference

    0

    3

    Giovanny Gongora

    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

    class Input extends Component {
      constructor() {
        super()
        this.myInput = React.createRef<HTMLInputElement>(null)
      }
      render() {
        return (
          <input ref={this.myInput} type='text' />
      	)
    	}
    }
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.