Skip to content

Commit

Permalink
Fixes reactjs#69: Adding capability to reduce production build output…
Browse files Browse the repository at this point in the history
… size and

allow users that import this package to include prop types in
development and optionally remove them using Webpacks UglifyJS + Define
plugin.
  • Loading branch information
virgofx committed Jun 3, 2017
1 parent e694fa5 commit c0aadb4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 47 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -57,6 +57,7 @@
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-transform-object-assign": "^6.22.0",
"babel-plugin-transform-react-remove-prop-types": "^0.4.5",
"babel-preset-latest": "^6.24.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-2": "^6.18.0",
Expand Down
34 changes: 16 additions & 18 deletions src/CSSTransitionGroup.js
Expand Up @@ -5,22 +5,6 @@ import TransitionGroup from './TransitionGroup';
import CSSTransitionGroupChild from './CSSTransitionGroupChild';
import { nameShape, transitionTimeout } from './utils/PropTypes';

const propTypes = {
transitionName: nameShape.isRequired,

transitionAppear: PropTypes.bool,
transitionEnter: PropTypes.bool,
transitionLeave: PropTypes.bool,
transitionAppearTimeout: transitionTimeout('Appear'),
transitionEnterTimeout: transitionTimeout('Enter'),
transitionLeaveTimeout: transitionTimeout('Leave'),
};

const defaultProps = {
transitionAppear: false,
transitionEnter: true,
transitionLeave: true,
};

class CSSTransitionGroup extends React.Component {

Expand Down Expand Up @@ -53,7 +37,21 @@ class CSSTransitionGroup extends React.Component {
}
}

CSSTransitionGroup.propTypes = propTypes;
CSSTransitionGroup.defaultProps = defaultProps;
CSSTransitionGroup.propTypes = {
transitionName: nameShape.isRequired,

transitionAppear: PropTypes.bool,
transitionEnter: PropTypes.bool,
transitionLeave: PropTypes.bool,
transitionAppearTimeout: transitionTimeout('Appear'),
transitionEnterTimeout: transitionTimeout('Enter'),
transitionLeaveTimeout: transitionTimeout('Leave'),
};

CSSTransitionGroup.defaultProps = {
transitionAppear: false,
transitionEnter: true,
transitionLeave: true,
};

export default CSSTransitionGroup;
29 changes: 14 additions & 15 deletions src/CSSTransitionGroupChild.js
Expand Up @@ -26,20 +26,6 @@ function addEndListener(node, listener) {
};
}

const propTypes = {
children: PropTypes.node,
name: nameShape.isRequired,

// Once we require timeouts to be specified, we can remove the
// boolean flags (appear etc.) and just accept a number
// or a bool for the timeout flags (appearTimeout etc.)
appear: PropTypes.bool,
enter: PropTypes.bool,
leave: PropTypes.bool,
appearTimeout: PropTypes.number,
enterTimeout: PropTypes.number,
leaveTimeout: PropTypes.number,
};

class CSSTransitionGroupChild extends React.Component {

Expand Down Expand Up @@ -176,6 +162,19 @@ class CSSTransitionGroupChild extends React.Component {
}
}

CSSTransitionGroupChild.propTypes = propTypes;
CSSTransitionGroupChild.propTypes = {
children: PropTypes.node,
name: nameShape.isRequired,

// Once we require timeouts to be specified, we can remove the
// boolean flags (appear etc.) and just accept a number
// or a bool for the timeout flags (appearTimeout etc.)
appear: PropTypes.bool,
enter: PropTypes.bool,
leave: PropTypes.bool,
appearTimeout: PropTypes.number,
enterTimeout: PropTypes.number,
leaveTimeout: PropTypes.number,
};

export default CSSTransitionGroupChild;
24 changes: 10 additions & 14 deletions src/TransitionGroup.js
Expand Up @@ -6,18 +6,6 @@ import warning from 'warning';
import { getChildMapping, mergeChildMappings } from './utils/ChildMapping';


const propTypes = {
component: PropTypes.any,
childFactory: PropTypes.func,
children: PropTypes.node,
};

const defaultProps = {
component: 'span',
childFactory: child => child,
};


class TransitionGroup extends React.Component {
static displayName = 'TransitionGroup';

Expand Down Expand Up @@ -243,7 +231,15 @@ class TransitionGroup extends React.Component {
}
}

TransitionGroup.propTypes = propTypes;
TransitionGroup.defaultProps = defaultProps;
TransitionGroup.propTypes = {
component: PropTypes.any,
childFactory: PropTypes.func,
children: PropTypes.node,
};

TransitionGroup.defaultProps = {
component: 'span',
childFactory: child => child,
};

export default TransitionGroup;

0 comments on commit c0aadb4

Please sign in to comment.