# react-ref

> Set reference to an element in React components

Latest version **0.0.1** (published 2016-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-ref
pnpm add react-ref
yarn add react-ref
bun add react-ref
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2016-09-12 |
| First published | 2016-09-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sam Gluck |
| Maintainers | sdgluck |
| Keywords | react, ref, reference |

## Links

- npm: https://www.npmjs.com/package/react-ref
- npm.io page: https://npm.io/package/react-ref

## Dependencies (1)

- [react](https://npm.io/package/react.md) ^15.3.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2016-09-12

## README

# react-ref

> :point_right: Set reference to an element in React components 

Made with ❤ at [@outlandish](http://www.twitter.com/outlandish)

<a href="http://badge.fury.io/js/react-ref"><img alt="npm version" src="https://badge.fury.io/js/react-ref.svg"></a>
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)

## Install

__API__

```sh
npm install --save react-ref
```

__CLI__

```sh
npm install --global react-ref
```

## Import

```js
// ES6
import ref from 'react-ref'
```

```js
// 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:

```js
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](https://egghead.io/lessons/javascript-identifying-how-to-contribute-to-an-open-source-project-on-github)!

## Author & License

`react-ref` was created by [Sam Gluck](https://twitter.com/sdgluck) and is released under the MIT license.

---
_Source: https://npm.io/package/react-ref · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
