react-hook-usemutable
v1.0.0
Published
Utilities to use the mutableJS library with React
Downloads
12
Maintainers
Readme
react-hook-usemutable
A utility to simplify the use of the @mutableJS/core reactivity with React.
Installation
Install with npm:
npm install @mutablejs/core react-hook-usemutable
Install with yarn:
yarn add @mutablejs/core react-hook-usemutable
Keep in mind the repository depends on the @mutablejs/core
package.
Usage/Examples
initialize inside of components
import { mutable } from '@mutablejs/core';
import useMutable from 'react-hook-usemutable';
const magicValue = mutable(0);
// Demoing value change
setInterval(() => {
magicValue.value++;
}, 500);
function ShowSomeMagic() {
const value = useMutable(magicValue);
return `Current value: ${value}`;
}
As a state container / store
import { mutable } from '@mutablejs/core';
import { createUseMutable } from 'react-hook-usemutable';
const magicValue = mutable(0);
const useMagicValue = createUseMutable(magicValue);
// Demoing value change
setInterval(() => {
magicValue.value++;
}, 500);
function ShowSomeMagic() {
const value = useMagicValue();
return `Current value: ${value}`;
}
Authors
Feedback
Any feedback? Join our Discord server and reach out to us.
We are open to suggestions, ideas and collaboration.
Support
Love open source? Enjoying my project?
Your support can keep the momentum going! Consider a donation to fuel the creation of more innovative open source software.
| via Ko-Fi | Buy me a coffee | via PayPal | | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | | |