fix: handle undefined sorts/customColumns from lazy+StrictMode defaultProps bug#2651
Closed
mofojed wants to merge 1 commit intodeephaven:mainfrom
Closed
fix: handle undefined sorts/customColumns from lazy+StrictMode defaultProps bug#2651mofojed wants to merge 1 commit intodeephaven:mainfrom
mofojed wants to merge 1 commit intodeephaven:mainfrom
Conversation
…tProps bug When IrisGrid is loaded via LazyIrisGrid (the public export), it goes through a forwardRef -> lazy() -> Suspense chain. In React 18 StrictMode, there is a known bug (facebook/react#28505) where defaultProps are not correctly merged into this.props during the second componentDidMount call of the StrictMode double-mount cycle. The root cause is in React's reconciler: during the simulated unmount, componentWillUnmount sets instance.props to fiber.memoizedProps (the unresolved props without defaultProps merged). When React re-mounts the component, componentDidMount sees these unresolved props, so props like sorts and customColumns are undefined instead of their defaultProps values (EMPTY_ARRAY). loadTableState() then sets these undefined values into state, and IrisGridModelUpdater crashes with 'sorts is not iterable' when it tries to spread them: `[...sorts]`. Add defensive ?? EMPTY_ARRAY fallbacks in: - IrisGrid.loadTableState(): when setting sorts/customColumns into state - IrisGridModelUpdater: when spreading sorts and assigning customColumns Add tests that reproduce the exact bug by combining async lazy loading with StrictMode, and unit tests for IrisGridModelUpdater with undefined sorts/customColumns.
Member
Author
|
The bug is a React issue: facebook/react#28505 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
When IrisGrid is loaded via LazyIrisGrid (the public export), it goes
through a forwardRef -> lazy() -> Suspense chain. In React 18 StrictMode,
there is a known bug (facebook/react#28505) where defaultProps are not
correctly merged into this.props during the second componentDidMount
call of the StrictMode double-mount cycle.
The root cause is in React's reconciler: during the simulated unmount,
componentWillUnmount sets instance.props to fiber.memoizedProps (the
unresolved props without defaultProps merged). When React re-mounts the
component, componentDidMount sees these unresolved props, so props like
sorts and customColumns are undefined instead of their defaultProps
values (EMPTY_ARRAY).
loadTableState() then sets these undefined values into state, and
IrisGridModelUpdater crashes with 'sorts is not iterable' when it
tries to spread them:
[...sorts].Add defensive ?? EMPTY_ARRAY fallbacks in:
Add tests that reproduce the exact bug by combining async lazy loading
with StrictMode, and unit tests for IrisGridModelUpdater with undefined
sorts/customColumns.