3

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') ?

twasbrillig
  • 14,704
  • 9
  • 39
  • 61
Giant Elk
  • 4,947
  • 9
  • 42
  • 55

1 Answers1

3

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.

Brigand
  • 80,366
  • 19
  • 159
  • 169
  • 3
    In the 0.14 version of React you'll get a warning from `require('react/addons')` - use `var ReactCSSTransitionGroup = require('react-addons-css-transition-group');` instead – Matt Holland Nov 30 '15 at 23:51