High performance cross-component state management.
use-quantum-state
is a specialized React hook designed to facilitate efficient state management in scenarios where components need to subscribe to specific values within a shared context. The core of this library relies on an EventEmitter
and useState
/ useEffect
hooks to manage listeners during a component's lifecycle.
See here for full documentation.
When a component in a render tree consumes context, it rerender when the provider's value is replaced. With this library, the provider's value IS NOT replaced when a subscriber emits updates, thus limiting the number of components that will be rendered to only those that also subscribe to the same property within state.
This library is particularly useful in niche cases, such as within the cells of a table, where it can dramatically reduce render cycles and simplify the management of state. However, it is not intended to serve as a general-purpose state management solution.
└── ./
├── src
│ ├── __tests__
│ └── index.tsx
├── LICENSE
├── README.md
├── api-extractor.json
├── eslint.config.mts
├── jest.config.js
├── package.json
├── tsconfig.build.json
├── tsconfig.json
├── turbo.json
└── typedoc.json
System Requirements:
Minimum Version | |
---|---|
node |
20.10.0 |
pnpm |
9.7.0 |
$ npm install use-quantum-state
OR
$ yarn add use-quantum-state
OR
$ pnpm add use-quantum-state
If you don't use turbo, you can still run the scripts via you package manager instead.
Run the test suite:
$ turbo test
Compile the library (this will also regenerate
/docs
):$ turbo build
Generate an API report
$ turbo report
Contributions are welcome! Here are several ways you can contribute:
- Report Issues: Submit bugs found or log feature requests for the
.
project. - Submit Pull Requests: Review open PRs, and submit your own PRs.
- Join the Discussions: Share your insights, provide feedback, or ask questions.
Contributing Guidelines
- Fork the Repository: Start by forking the project repository to your local account.
- Clone Locally: Clone the forked repository to your local machine using a git client.
git clone ../.
- Create a New Branch: Always work on a new branch, giving it a descriptive name.
git checkout -b new-feature-x
- Make Your Changes: Develop and test your changes locally.
- Regenerate The API Report: This makes sure any breaking changes are easy to spot during review.
turbo report
- Commit Your Changes: Commit with a clear message describing your updates following the conventional commit spec.
git commit -m 'feat: implemented new feature x.'
- Push to local: Push the changes to your forked repository.
git push origin new-feature-x
- Submit a Pull Request: Create a PR against the original project repository. Clearly describe the changes and their motivations.
- Review: Once your PR is reviewed and approved, it will be merged into the main branch. Congratulations on your contribution!
This project is protected under the MIT License. For more details, refer to the LICENSE file.