Core: Only call setup function on story navigation #15244
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue: N/A
What I did
CSF3 (experimental) introduces a
setup
function that gets called after every story render. The problem is that if you update the controls, it causes thesetup
function to re-render, and args changes can result in elements not being on screen when thesetup
function needs them.The solution in this PR is to not run the setup function when (the confusingly named)
forceRender
is set.forceRender
means that there was no story navigation and we want to force the story to re-render for some other reason.How to test
See the
AccountForm
"Verification Password Mismatch" demo inexamples/react-ts
. After the setup function finishes, toggle thepasswordVerification
boolean. This causes a crash prior to this PR, but simply adjusts the prop as expected after this PR.self-merging @tmeasday