Skip to content

Commit

Permalink
Fix Transition passes through all props to children in production build
Browse files Browse the repository at this point in the history
  • Loading branch information
koba04 committed Jul 21, 2017
1 parent 20b16c6 commit 0987135
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,21 @@ class Transition extends React.Component {
}

const {children, ...childProps} = this.props;
Object.keys(Transition.propTypes).forEach(key => delete childProps[key]);
// 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;

if (typeof children === 'function') {
return children(status, childProps)
Expand Down
34 changes: 34 additions & 0 deletions test/Transition-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,40 @@ describe('Transition', () => {
.render();
});

it('should pass filtered props to children', () => {
class Child extends React.Component {
render() {
return <div>child</div>;
}
}
const child = tsp(
<Transition
foo="foo"
bar="bar"
in
mountOnEnter
unmountOnExit
appear
enter
exit
timeout={0}
addEndListener={() => {}}
onEnter={() => {}}
onEntering={() => {}}
onEntered={() => {}}
onExit={() => {}}
onExiting={() => {}}
onExited={() => {}}
>
<Child />
</Transition>
)
.render()
.find(Child);

expect(child.props()).toEqual({foo: 'foo', bar: 'bar'});
});

describe('entering', () => {
let instance;

Expand Down

0 comments on commit 0987135

Please sign in to comment.