Upgrade packages and add data reconciliation to RTK app #519
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.
It turns out that React 18+ and/or Next 13+ no longer allow our
useMemo
solution to always work properly. In the previous versions, when doing client side routing, React would not rerender the currently mounted components after we hydrated, and would instead directly mount the new components for the new page. In React 18+ and Next 13+, that's no longer the case. React now does rerender the currently mounted components before mounting the new page components. At least that's what happened in the RTK demo app in this repo.This means users probably have to do data reconciliation if their old page has selectors in them.
As discussed before, this won't happen on every page on every client side routing event, but it may happen sometimes. I don't know what it depends on, but I think it's best if users always do it.
Note that this has already been happening to users that are already on React 18+ and/or Next 13+, so this package upgrade PR won't affect anything. These problems already exist.
The only thing we probably need to do is inform users that they have to do data reconciliation (if they run into this issue).