问题
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')
?
回答1:
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.
来源:https://stackoverflow.com/questions/26965897/not-working-requirereact-addons