Package Exports
- react-create-ref
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-create-ref) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
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>
)
}
}