0.5.0 • Published 7 years ago

createref v0.5.0

Weekly downloads
103
License
MIT
Repository
github
Last release
7 years ago

createRef

Build Status npm version

A React.createRef emulation for React < 16.3

Installation

npm i --save createref

Usage

Usage is much the same as React.createRef except that createRef must be imported separately because it is not available from the React package.

See Creating Refs in the official React documentation for further details.

import React from 'react';
import createRef from 'createref';

class MyComponent extends React.Component {
  contructor(props) {
    super(props);

    // assign the ref to the component instance
    this.myRef = createRef();
  }

  doSomething() {
    // the element can be accessed on the current property of the ref
    console.log(this.myRef.current);
  }

  render() {
    // pass the ref to the rendered element
    return <div ref={this.myRef} />;
  }
}

See the examples directory for more

0.4.0

7 years ago

0.5.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.0.7

7 years ago

0.0.8

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago