Giant Elk
Giant Elk

Reputation: 5685

Not working: require('react/addons')

I'm using ReactJS & Browserify. I can't figure out why this require doesn't give me access to ReactCSSTransitionGroup:

    var React = require('react/addons');

I tried adding this and it's still not working:

    var ReactCSSTransitionGroup = React.ReactCSSTransitionGroup;

To get it working I had to add:

    var ReactCSSTransitionGroup = require("react/lib/ReactCSSTransitionGroup");

How can I gain access to all addons through: require('react/addons') ?

Upvotes: 3

Views: 3540

Answers (1)

Brigand
Brigand

Reputation: 86270

Requiring 'react/addons' simply adds the addons object to React and exports React.

React.addons = {
  CSSTransitionGroup: ReactCSSTransitionGroup,
  LinkedStateMixin: LinkedStateMixin,
  ...

module.exports = React;

As in the docs you can find the animation addon at React.addons.CSSTransitionGroup.

Side note: requiring 'react' and 'react/addons' doesn't include react twice. Some people have asked about that in the past, so I just want to clarify.

Upvotes: 3

Related Questions