snagi / react-mirror

Takes control over the component's rendering cycle allowing many synchronized replicas of its DOM.

Home Page:http://theadd.github.io/react-mirror/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

react-mirror

react-mirror

Mirror any react component.

Given any wrapped react component, e.g. <Surface>component</Surface>, react-mirror allows you to mirror those components within any other component's render method, placing any number of <Mirror />.

DEMO + PLAYGROUND

react-mirror

-- Each mirror is a full clone of the DOM Node it reflects, being replaced by a new clone for each reported mutation. Therefore, don't use this method in order to get a performance boost. --

API

js-standard-style

Sample Usage

class Demo extends Component {

  componentDidMount () {
    this.refs.mirror.reflect(this.refs.surface)
  }

  render () {
  
    return (
      <div>
        <Surface ref="surface">
          <SomeOtherComponent />
        </Surface>
        <Mirror ref="mirror" />
      </div>
    )
  }
}

<Surface />

Surface will render any react component without being appended to the DOM tree.

PARAMS DEFAULT DESCRIPTION
initialMirror true Automatically creates a Mirror for this Surface.
equalityTest true Accepts any primitive value (taken as boolean) or a function to retrieve that value given previous and next props from the wrapped component as arguments.
This value represents the equality comparison of the given arguments. So, when NOT positive, it will update Surface's internal ReactElement with the next one.
* If you pretend to pass down updated props to the wrapped component you have to specify some other value than true here. Like false or any shallowEqual implementation out there.

<Mirror />

Mirror.reflect([object surface])

Changes the `Surface` being reflected by this mirror. Stops mirroring when no surface is specified (or `null`).

About

Takes control over the component's rendering cycle allowing many synchronized replicas of its DOM.

http://theadd.github.io/react-mirror/

License:MIT License


Languages

Language:JavaScript 100.0%