Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-ref

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-ref

Set reference to an element in React components

  • 0.0.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-ref

:point_right: Set reference to an element in React components

Made with ❤ at @outlandish

npm version js-standard-style

Install

API

npm install --save react-ref

CLI

npm install --global react-ref

Import

// ES6
import ref from 'react-ref'
// CommonJS
var ref = require('react-ref')

Usage

ref(instance, name)

  • instance {Object} React component
  • name {String} Name of property to attach element reference

Returns a function.

Example:

class Input extends React.Component {
  focus () {
    this.input.focus()  
  }
  
  clear () {
    this.input.value = ''  
  }
  
  render () {
    return (
      <div className='Input'>
        <input type='text' ref={ref(this, 'input')} />
      </div>
    )  
  }
}

Contributing

All pull requests and issues welcome!

If you're not sure how, check out Kent C. Dodds' great video tutorials on egghead.io!

Author & License

react-ref was created by Sam Gluck and is released under the MIT license.

Keywords

FAQs

Package last updated on 12 Sep 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc