Skip to content

require('react') != require('react/addons') #2456

@tkafka

Description

@tkafka

I am building frontend with browserify (+ reactify), and I found out, that when some of my components use var React = require('react'); and others use var React = require('react/addons'); then it seems like that each set of components has a different instance of React that don't talk to each other.

This means that if I instantiate my app with

var React = require('react'); // no addons
var App = require('./components/App.jsx');
React.render(<App />, document.body);

while my components use var React = require('react/addons'); // with addons, then it seems that any events fired by such components aren't handled (for example onClick={this.onClick} isn't called) - seemingly because their instance of React is different one than the instance that rendered the root.

When I replaced all require('react') calls in my app with require('./oneReact.js') where oneReact.js looks like this:

var React = require('react/addons');
module.exports = React;

all events started being handled again.

Is this behavior a bug or by design?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions