Hi,
I wrote a component Switch: https://codesandbox.io/s/m5oy50k649
When I use React and ReactDom@16.4.1, getDerivedStateFromProps will be called everytime before the render method.

but when I use React and ReactDom@15.0.0, and with this polyfill, getDerivedStateFromProps is called just before the first render, as my example shows. This is not what I expected.

React Doc:
getDerivedStateFromProps is invoked right before calling the render method, both on the initial mount and on subsequent updates
Here's what I want:
Switch has a state checked, and a prop checked as well.
if <Switch />, the component can work because it has it's own state checked;
if <Switch checked />, the component will never change state, because before every render, getDerivedStateFromProps will reset the components' checked.
But when React and ReactDom@15.0.0, It doesn't work as I expected.
Thanks for helping.
Hi,
I wrote a component Switch: https://codesandbox.io/s/m5oy50k649
When I use React and ReactDom@16.4.1,

getDerivedStateFromPropswill be called everytime before therendermethod.but when I use React and ReactDom@15.0.0, and with this polyfill,

getDerivedStateFromPropsis called just before the firstrender, as my example shows. This is not what I expected.React Doc:
Here's what I want:
Switchhas a statechecked, and a propcheckedas well.if
<Switch />, the component can work because it has it's own statechecked;if
<Switch checked />, the component will never change state, because before everyrender,getDerivedStateFromPropswill reset the components'checked.But when React and ReactDom@15.0.0, It doesn't work as I expected.
Thanks for helping.