New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

createref

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

createref

A React.createRef emulation for React < 16.3

latest
Source
npmnpm
Version
0.5.0
Version published
Maintainers
1
Created
Source

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

Keywords

React

FAQs

Package last updated on 11 Apr 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts