Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jossmac/react-node-resolver

🔍 Resolve the DOM node of any react component
https://github.com/jossmac/react-node-resolver

dom element node react resolver

Last synced: 3 months ago
JSON representation

🔍 Resolve the DOM node of any react component

Awesome Lists containing this project

README

        

# React Node Resolver

A generic technique for resolving the DOM node of any react component.

[![Build Status](https://travis-ci.org/jossmac/react-node-resolver.svg?branch=master)](https://travis-ci.org/jossmac/react-node-resolver)

### Alternative Solutions

Since creating this utility, more robust solutions have become available. Consider the following before using this package:

- [React.forwardRef()](https://reactjs.org/docs/forwarding-refs.html)
- [The render props pattern](https://reactjs.org/docs/render-props.html)

### Install

```bash
yarn add react-node-resolver
```

### Use

```jsx
import NodeResolver from 'react-node-resolver';

class ObfuscatedComponent extends Component {
render() {
return

;
}
}

class GroovyThing extends Component {
getNode = (ref) => {
console.log(ref); //


}
render () {
return (



);
}
}
```

### Props

| Property | Type | Description |
| ---------------- | ------------ | ----------- |
| `children` | `Element` | A single react Component |
| `innerRef` | `ElementRef` | Callback ref `ref => this.node = ref` |