Use Context Selector
use-context-selector
React useContextSelector hook in userland
Hooks
react
context
hooks
use-context-selector
javascript
npm
frontend
open source
ui
library
Stars
436
Weekly
1.9M
Open issues
5
Bundle
~25 kB
Installation
npm install use-context-selectorCode example
import { useContextSelector } from "use-context-selector";
export function Example() {
const value = useContextSelector();
return <p>{String(value)}</p>;
}Pros & cons
Pros
- Actively maintained by Daishi Kato
- 1.9M weekly downloads. Battle tested
- First-class TypeScript definitions
- MIT licensed
Considerations
- Adds roughly ~25 kB to your bundle
- Needs client-only rendering in SSR frameworks
- Not supported in React Native
- 5 open issues on GitHub