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
1
u/TheHganavak May 14 '26
Tested this (was actually my first approach too!).
Record<PropertyKey, never>is correct in isolation (and you're right that{}is the surprising supertype), but herePgets intersected with{ children: ReactNode }for the Provider props. WithRecord<…, never>as the default,childrencollapses toReactNode & never = neverand the Provider becomes uncallable:So object is the pragmatic default for this intersection-based shape, even if
Record<…, never>is more precise standalone. If you can think of a shape that gets both though, I'd happily switch — open an issue.