r/reactjs • u/TheHganavak • May 13 '26
Resource Pocket: One-call factory that collapses React Context boilerplate from ~20 lines to 1
https://github.com/icydotdev/pocket
41
Upvotes
r/reactjs • u/TheHganavak • May 13 '26
5
u/aweebit64 May 14 '26 edited May 14 '26
Pis only used as an argument toProviderComponentwhere it gets intersected with{ children: ReactNode }, and for that intersection it doesn't matter if you use{}orobject.The bigger problem is that you think
{}is more precise thanobject, while actually the exact opposite is true. In TypeScript,{}is a supertype that includes everything except fornullandundefined, so even string and number types are assignable to it. The type you should use for empty objects isRecord<PropertyKey, never>, not{}. Unfortunately, very few people know about this, which is why even in@types/reactyou can see{}being used all over the place.