Nondeterministic Postrequisite Metaprotocol

npm

Need private packages and team management tools?Check out npm Orgs. »

react-child-by-ref-decorator

3.0.1 • Public • Published

react-child-by-ref-decorator

ECMA-6 Decorator for separate React children by ref property

Micro decorator allows you to access child node by ref property. Decorator wraps base component into component and transmits associated object through childrenByRef property into base component

Example

// Inner component
import childByRefWrapper from 'react-child-by-ref-decorator';

@childByRefWrapper
export default class Switcher extends React.Component {

  render() {
    return <div>
      <div>{this.props.childrenByRef.refA}</div>
      <div>{this.props.childrenByRef.refB}</div>
    </div>;
  }
}


// Main component
import Switcher from 'Switcher';
export default class Main extends React.Component {

  render() {
    return <Switcher>
      <div ref="refA"></div>
      <div ref="refB"></div>
      <div ref="refC"></div>
    </Switcher>;
  }
}

install

npm i react-child-by-ref-decorator

Downloadsweekly downloads

4

version

3.0.1

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability