-
Notifications
You must be signed in to change notification settings - Fork 410
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
Changing size dynamically doesn't work in strict mode #309
Comments
I've started trying to put a PR together to fix this but I have gotten stuck with Note this test passes if you remove the I have no idea why it would be that if |
Even if I do not use |
@kidkkr - do you have a reproduction? If I remove the |
Sorry. I did misunderstand situation. https://codesandbox.io/s/o9ly13qovy it works well. 😃 |
I haven't had much experience with StrictMode but Ill dig around. |
This test is a reproduction for tomkp#309 and so is currently failing. There is some complexity in making it work but it reproduces the problem.
I'm not sure if this is the best solution for tomkp#309, as I am not entirely aware of what this code was trying to do, but it *seemed* like it was trying to avoid touching state too much which doesn't seem super useful as there wasn't any complex calculations involved -- and if there was, memoization would be more useful. In any case it was triggering problems in strict mode which implies it would have broken in later version of React.
OK, my PR now works: #315 cc @wuweiweiwu |
Awesome! I'll take a look ASAP @tmeasday |
* Update to React@16.4 and add a test for strict mode This test is a reproduction for #309 and so is currently failing. There is some complexity in making it work but it reproduces the problem. * Don't try and avoid updating state I'm not sure if this is the best solution for #309, as I am not entirely aware of what this code was trying to do, but it *seemed* like it was trying to avoid touching state too much which doesn't seem super useful as there wasn't any complex calculations involved -- and if there was, memoization would be more useful. In any case it was triggering problems in strict mode which implies it would have broken in later version of React.
Released in 0.1.83!! |
Describe the bug
Dynamically changing the
size
has no effect in React strict mode, either programatically or via devtools.To Reproduce
Steps to reproduce the behavior:
size
prop to some other valueExpected behavior
Changing the
size
prop should change the size of the fixed pane.Additional context
As the
getDerivedStateFromProps
function is state dependent (it state based on the previous state), in React's strict mode it gets tripped by this sort-of zany check:https://github.com/facebook/react/blob/067cc24f55ef01a233be9e7564b337e35fed72ea/packages/react-reconciler/src/ReactFiberClassComponent.js#L139-L148
So when you change
props
,getDerivedStateFromProps
gets called twice and the second time, this check returnsfalse
, sonewState.paneXsize
is not set:react-split-pane/src/SplitPane.js
Lines 235 to 238 in ec8d4ae
I could have this explanation wrong, I'll admit it's pretty confusing.
The text was updated successfully, but these errors were encountered: