Skip to content

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

License

Notifications You must be signed in to change notification settings

Theadd/react-mirror

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-mirror

react-mirror

This was developed for React v0.14 and it doesn't work in newer versions. See Emmanuel Ogbizi's react-mirror as an alternative.

No Maintenance Intended

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 />.

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published