Skip to content

[utils] Import Store changes from x-internals#4765

Open
romgrk wants to merge 6 commits into
mui:masterfrom
romgrk:refactor-store-merge
Open

[utils] Import Store changes from x-internals#4765
romgrk wants to merge 6 commits into
mui:masterfrom
romgrk:refactor-store-merge

Conversation

@romgrk
Copy link
Copy Markdown
Contributor

@romgrk romgrk commented May 7, 2026

This PR imports the Store changes from x-internals in preparation for deleting the duplicated code from the MUI X repository.

@romgrk romgrk added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. package: utils Specific to the utils package. labels May 7, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 7, 2026

commit: acd0f0c

@code-infra-dashboard
Copy link
Copy Markdown

code-infra-dashboard Bot commented May 7, 2026

Bundle size

Bundle Parsed size Gzip size
@base-ui/react 🔺+285B(+0.06%) 🔺+82B(+0.06%)

Details of bundle changes

Performance

Total duration: 1,148.38 ms +56.22 ms(+5.1%) | Renders: 50 (+0) | Paint: 1,753.27 ms +89.49 ms(+5.4%)

Test Duration Renders
Checkbox mount (500 instances) 83.01 ms 🔺+21.18 ms(+34.3%) 1 (+0)

11 tests within noise — details


Check out the code infra dashboard for more information about this PR.

@netlify
Copy link
Copy Markdown

netlify Bot commented May 7, 2026

Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit acd0f0c
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/6a064903276f3d000882d504
😎 Deploy Preview https://deploy-preview-4765--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

},
};

instance.subscribe();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This creates a store subscription before the component commits. In concurrent rendering, an abandoned render will not run the useOnMount cleanup, leaving a listener for an instance that never mounted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch. The useStoreEffect early subscription has always felt too hacky for my taste but it fixed initialization issues in some parts of the MUI X codebase. I'm going to remove the hook altogether from this PR and see if we can rework things there to get rid of it.

): void {
const instance = useRefWithInit(initialize, { store, selector }).current;
instance.effect = effect;
useOnMount(instance.onMount);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The hook updates only effect; initialize closes over the initial store and selector, and useOnMount never reruns. If a component receives a replacement store, or passes a selector that closes over props, updates continue to be computed from stale inputs while invoking the latest effect callback.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

JSDoc is stale after the arity change

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

New public store behavior is effectively untested.
The only changed test line widens an existing nested-store type. The PR adds/exports useStoreEffect, Store.create, createSelectorMemoizedWithOptions, single-combiner handling in createSelectorMemoized, and expanded createSelector arity, but none of those behaviors have focused regression tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: utils Specific to the utils package. type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants