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

refactor(ui): some react refactorings #31900

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

Skn0tt
Copy link
Member

@Skn0tt Skn0tt commented Jul 29, 2024

Addresses #31863. This PR is chonky, but the individual commits should be easy to review. If they're not, i'm happy to break them out into individual PRs.

There's two main things this does:

  1. Remove some unused imports
  2. Add a clsx-inspired helper function for classname templating

I wasn't able to replace ReactDOM.render with ReactDOM.createRoot. This is the new recommended way starting with React 18, and the existing one is going to be deprecated at some point. But it somehow breaks our tests, i'll have to investigate that separately.

@Skn0tt Skn0tt self-assigned this Jul 29, 2024

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Skn0tt
Copy link
Member Author

Skn0tt commented Jul 30, 2024

Interestingly, it looks like the createRoot().render() change broke lots of tests. I've reverted it in 3e198ce, let's see what CI says.

@Skn0tt Skn0tt marked this pull request as draft July 30, 2024 07:56

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Skn0tt added a commit that referenced this pull request Jul 30, 2024
…f prop drilling (#31911)

Broken out from #31900, part
of #31863.

Synchronizes different `useSettings` calls via `useSyncExternalStore`.
This saves us from having to drill down settings props everywhere,
without the big refactoring that a `Context` would be.
@Skn0tt Skn0tt marked this pull request as ready for review July 31, 2024 08:58
@Skn0tt Skn0tt requested a review from dgozman July 31, 2024 08:58

This comment has been minimized.

The vite/react plugin automatically inserts this import, so there's no need to have it in JSX files if it isn't used to import hooks.
https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md#jsxruntime
@Skn0tt Skn0tt merged commit 99724d0 into microsoft:main Jul 31, 2024
29 checks passed
Copy link
Contributor

Test results for "tests 1"

3 flaky ⚠️ [firefox-library] › library/browsercontext-fetch-happy-eyeballs.spec.ts:46:3 › get should work
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all
⚠️ [playwright-test] › ui-mode-test-watch.spec.ts:145:5 › should watch all

29510 passed, 702 skipped
✔️✔️✔️

Merge workflow run.

Skn0tt added a commit that referenced this pull request Jul 31, 2024
…dren into named properties (#31925)

Pulled out from #31900

I stumbled over `React.Children`, because it's the first time I saw that
used. https://react.dev/reference/react/Children lists `React.Children`
it as "Legacy" and mentions it's uncommon. Also, the fact that SplitView
only displays its first two children, and all others are silently
discarded, can be a surprise to some.

By separating things out into `sidebar` and `main`, not only do we give
the two elements names (otherwise one needs to remember that sidebar is
always the first child), but we also prevent any "third children" from
being dropped.
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.

None yet

3 participants