Skip to content

hasnainroopawalla/react-sliced-context

Repository files navigation

react-sliced-context

Minified Size

A small utility to create React Contexts that allow components to subscribe to specific keys (slices) of the context value to avoid unnecessary re-renders.

Inspired by the need to optimize context updates by only re-rendering components that depend on the changed slice of the context value.

Install

npm install react-sliced-context
# or
yarn add react-sliced-context

For the example project in this repository, run yarn in the example folder and then yarn start.

Quick Example

Check the example package.

Testing

This repository includes unit tests. From the repo root run:

yarn test

or from the example folder:

cd example
yarn
yarn start

Contributing

Contributions are welcome. Please open issues for bugs or feature requests and create PRs for fixes.

License

MIT

About

Tiny React Context with key-based subscriptions to prevent unnecessary re-renders.

Topics

Resources

License

Stars

Watchers

Forks