Skip to content

catamphetamine/react-create-ref

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

React.createRef() polyfill for React < 16.3

Install

npm install react-create-ref --save

Use

Calls native React.createRef() if it's available (React >= 16.3), calls the polyfill function otherwise (React < 16.3).

import createRef from 'react-create-ref'

class Example extends React.Component {
  constructor() {
    this.input = createRef()
  }

  render() {
    return (
      <form>
        <input type="text" ref={this.input} />
        <button type="button" onClick={() => this.input.current.focus()} />
      </form>
    )
  }
}

About

React.createRef() polyfill

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published