Uh oh!
There was an error while loading. Please reload this page.
Add ConsumeContext - #756
Conversation
🦋 Changeset detectedLatest commit: e71e4ad 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 |
thetarnav
commented
Feb 15, 2025
this is a cool idea, but I don't like how you need a bound function (without parameters) to use it. When the default solid api for using the context is <Provider>{untrack(()=>{constvalue=useContext(Ctx)return<>{value}</>})}</Provider> |
FabianHummel
commented
Feb 15, 2025
If you mean the <ConsumeContextcontext={counterContext}>{(ctx)=><>...</>}</ConsumeContext>// or<ConsumeContextuseFn={useCounter}>{(ctx)=><>...</>}
</ConsumeContext>And for the easy alternative: |
FabianHummel
commented
Feb 16, 2025
Implemented the aforementioned ideas and added tests + docs |
thetarnav
commented
Feb 16, 2025
what about <ConsumeContextuse={useMyContext}><ConsumeContextuse={()=>useContext(MyContext)}><ConsumeContextuse={MyContext}>by simply checking the Also it may be useful to mention in the docs that the prop will not be reactive. |
FabianHummel
commented
Feb 17, 2025
Oh, I totally forgot about this option, I will implement it later that day, thanks! |
davedbase
commented
May 3, 2026
Hey there! It's been quite a while since this was first introduced. We're working on Solid 2.0 migration right now and would like to consider this for the porting. Do you have time to finish off the current work for 1.0 or possibly support 2.0 directly? |
FabianHummel
commented
May 3, 2026
Hi, I am pleased to see this PR regaining some attention, it kind of went under my radar to be honest 😅 It's cool to see progress being made on SolidJS and I would still love to contribute to its ecosystem. I can invest some time updating this PR to Solid 2.0 if it's fine for you. Are there things I need to look out for like changing the branch, or can I continue work as usual? |
davedbase
commented
May 3, 2026
I'd recommend merging in main to ensure you're on latest and you can continue working as you'd like. Can land 1.0, publish and get a 2.0 or going. :) |
davedbase
commented
Jul 4, 2026
@FabianHummel just checking in to see if you're still interested in migrating this? We landed a |
FabianHummel
commented
Jul 5, 2026
Hello @davedbase, I did manage to migrate my changes to version 2.0. However, due to internal changes to how Also, do I need to create a new PR or can I somehow reuse this one? I created a new branch |
davedbase
commented
Jul 5, 2026
@FabianHummel you should branch off of the |
Add a function to directly consume contexts within JSX. Inspired by React's
Context.Consumercomponent, but nicely integrated with this primitive'screateContextProvider.Tests have been added and source code + README.md is documented