upgrade: context package upgrade for Solid 2.0#907
Draft
davedbase wants to merge 2 commits into
Draft
Conversation
🦋 Changeset detectedLatest commit: 943027f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Migrates
@solid-primitives/contextto Solid.js 2.0 (beta.13) and adds three quality-of-life additions to the API.Solid 2.0 migration (breaking)
Context.Providerremoved — In Solid 2.0, theContextobject itself is the provider component.createContextProviderandMultiProviderupdated;<MyCtx.Provider value={...}>becomes<MyCtx value={...}>.ContextProviderComponentimport fixed — Previously imported from an internalnode_modulespath; now a proper export fromsolid-js.JSX.Element→Element— Public API types now useElementfromsolid-js(renderer-neutral), matching the Solid 2.0 type model.MultiProvidercleanup — Removed the.Providerfallback branch;Contextis always a function in Solid 2.0.solid-js@^2.0.0-beta.13and@solidjs/web@^2.0.0-beta.13required.1.0.0(major).Noteworthy Solid 2.0 behaviour: context providers now wrap children in a lazy memo (
children(() => props.children)). Tests that previously used barecreateRoot(() => { <Provider/>; })never forced child evaluation. TheMultiProviderbrowser test was updated to userender()so the DOM renderer drives evaluation of the lazy memo chain.New exports
createStrictContextProviderLike
createContextProviderwithout defaults, but with the contract made explicit in types: the hook returnsT(neverT | undefined), and Solid throwsContextNotFoundErrorat runtime when called outside a provider. Accepts an optional{ name }for DevTools labeling.createLayeredContextEach provider extends the parent context value rather than replacing it. The factory receives
(props, parent)whereparentis the nearest enclosing provider's value (falling back todefaultsat the root). You control the merge strategy.Useful for themes, permission layers, i18n patches, and any context where child providers should inherit what they don't explicitly override.
ContextProviderOptions+nameoncreateContextProviderAll three primitives accept
{ name?: string }for the Solid DevTools Symbol label. OncreateContextProviderit's the third argument (with-defaults overload only):