diff --git a/src/Transition.js b/src/Transition.js index 116852e3..b4964bd9 100644 --- a/src/Transition.js +++ b/src/Transition.js @@ -341,42 +341,38 @@ class Transition extends React.Component { render() { const status = this.state.status + if (status === UNMOUNTED) { return null } - const { children, ...childProps } = this.props - // filter props for Transtition - delete childProps.in - delete childProps.mountOnEnter - delete childProps.unmountOnExit - delete childProps.appear - delete childProps.enter - delete childProps.exit - delete childProps.timeout - delete childProps.addEndListener - delete childProps.onEnter - delete childProps.onEntering - delete childProps.onEntered - delete childProps.onExit - delete childProps.onExiting - delete childProps.onExited - delete childProps.nodeRef - - if (typeof children === 'function') { - // allows for nested Transitions - return ( - - {children(status, childProps)} - - ) - } + const { + children, + // filter props for `Transition` + in: _in, + mountOnEnter: _mountOnEnter, + unmountOnExit: _unmountOnExit, + appear: _appear, + enter: _enter, + exit: _exit, + timeout: _timeout, + addEndListener: _addEndListener, + onEnter: _onEnter, + onEntering: _onEntering, + onEntered: _onEntered, + onExit: _onExit, + onExiting: _onExiting, + onExited: _onExited, + nodeRef: _nodeRef, + ...childProps + } = this.props - const child = React.Children.only(children) return ( // allows for nested Transitions - {React.cloneElement(child, childProps)} + {typeof children === 'function' + ? children(status, childProps) + : React.cloneElement(React.Children.only(children), childProps)} ) }