Skip to content
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

chore(recorder): update to React 18 #32101

Merged
merged 2 commits into from
Aug 12, 2024
Merged

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Aug 9, 2024

Part of #31863. Updates recorder to use React 18.

@Skn0tt Skn0tt requested a review from mxschmitt August 9, 2024 14:38
@Skn0tt Skn0tt self-assigned this Aug 9, 2024
@@ -30,12 +30,14 @@ export const Main: React.FC = ({
window.playwrightSetSources = setSources;
window.playwrightSetPaused = setPaused;
window.playwrightUpdateLogs = callLogs => {
const newLog = new Map<string, CallLog>(log);
Copy link
Member Author

@Skn0tt Skn0tt Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this closes over log from the outer scope, at the point in time where the closure is created. If log changes, e.g. because setLog is called, this will only be picked up if the component rerenders and the callback is reset. Before Concurrent React, apparently this component was rerendered often enough. With Concurrent mode that doesn't work anymore, though, and log sometimes points to an old version of the logs, dropping updates that were applied in between renders :/

The fix is to use an updater function so we always update based on the current version of the state, no matter when Main is rerendered.

Docs on updater function: https://react.dev/reference/react/useState#updating-state-based-on-the-previous-state

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great description!

This comment has been minimized.

Copy link
Contributor

Test results for "tests 1"

3 flaky ⚠️ [playwright-test] › ui-mode-test-setup.spec.ts:87:5 › should show errors in config
⚠️ [webkit-page] › page/page-goto.spec.ts:182:3 › should properly cancel Cross-Origin-Opener-Policy navigation
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all

29655 passed, 711 skipped
✔️✔️✔️

Merge workflow run.

@Skn0tt Skn0tt merged commit 45c2e8a into microsoft:main Aug 12, 2024
30 checks passed
Skn0tt added a commit that referenced this pull request Aug 12, 2024
Part of #31863. Updates
most of our React usage to React 18. `recorder` doesn't seem to like it
yet. I suspect that some of our code isn't compatible with concurrent
mode, i've investigated that in
#32101.

---------

Signed-off-by: Simon Knott <[email protected]>
Co-authored-by: Max Schmitt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants