Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oleystack/context
⚙️ React's Context-related utils.
https://github.com/oleystack/context
Last synced: 15 days ago
JSON representation
⚙️ React's Context-related utils.
- Host: GitHub
- URL: https://github.com/oleystack/context
- Owner: oleystack
- License: mit
- Created: 2023-03-10T19:19:18.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-07-20T07:45:15.000Z (over 1 year ago)
- Last Synced: 2025-01-04T22:06:02.020Z (21 days ago)
- Language: TypeScript
- Size: 363 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@bit-about/context
## Install
```bash
npm i @bit-about/context
```## Description
Aimed at delivering context-related utils for @bit-about libraries.
- 100% **Idiomatic React** and 100% Typescript
- Tiny & Efficient
- Does not trigger unnecessary renderings
- as always, **Just works** ™## Usage
```tsx
import { createContext, useContextSelector } from '@bit-about/context'interface State {
alice: number;
bob: number;
}const defaultValue: State = {
alice: 1,
bob: 2
}const Context = createContext(defaultValue)
const App = () => (
)const Component = () => {
const bob = useContextSelector(Context, (state) => state.bob)return bob // returns "2"
}
```## Credits
- [use-context-selector](https://github.com/dai-shi/use-context-selector) & [FluentUI](https://github.com/microsoft/fluentui) - fancy re-render avoiding tricks and code main inspiration## License
MIT © [Maciej Olejnik 🇵🇱](https://github.com/macoley)## Support me
If you use my library and you like it...
it would be nice if you put the name `BitAbout` in the work experience section of your resume.
Thanks 🙇🏻!---
🇺🇦 Slava Ukraini