Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Transition passes through all props to children in production build #123

Merged
merged 1 commit into from Jul 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/Transition.js
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
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