Skip to content

Commit

Permalink
Warn on passing different props to super()
Browse files Browse the repository at this point in the history
  • Loading branch information
gaearon committed Dec 14, 2016
1 parent ddae7db commit aa92f74
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 0 additions & 1 deletion scripts/fiber/tests-passing-except-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js
* should warn about `forceUpdate` on unmounted components
* should warn about `setState` on unmounted components
* should disallow nested render calls
* should warn when mutated props are passed

src/renderers/shared/shared/__tests__/ReactMultiChild-test.js
* should warn for duplicated keys with component stack info
Expand Down
1 change: 1 addition & 0 deletions scripts/fiber/tests-passing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ src/renderers/shared/shared/__tests__/ReactCompositeComponent-test.js
* should replace state
* should support objects with prototypes as state
* should not warn about unmounting during unmounting
* should warn when mutated props are passed
* should only call componentWillUnmount once

src/renderers/shared/shared/__tests__/ReactCompositeComponentDOMMinimalism-test.js
Expand Down
8 changes: 8 additions & 0 deletions src/renderers/shared/fiber/ReactFiberClassComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ module.exports = function(scheduleUpdate : (fiber: Fiber) => void) {
'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?',
name
);
const hasMutatedProps = instance.props !== workInProgress.pendingProps;
warning(
instance.props === undefined || !hasMutatedProps,
'%s(...): When calling super() in `%s`, make sure to pass ' +
'up the same props that your component\'s constructor was passed.',
name,
name
);
}

const state = instance.state;
Expand Down

0 comments on commit aa92f74

Please sign in to comment.