2.0.3 β’ Published 1 month ago
@cervello/react v2.0.3
Cervello
π€― Simplest and truly reactive state manager for React (just 1.5kb)
π Features
- βοΈ Truly reactive on store change like normal objects without functions (nested properties too π!!)
- β Super simple and minimalistic API
- π¨ Listen properties lazily
- π No unnecessary re-renders
- π Immutable changes
- π Typescript support
π¦ Install
# NPM
npm install @cervello/react
# PNPM
pnpm add @cervello/react
# YARN
yarn add @cervello/react
π» Quick Usage
The cervello
function allows you to create a new store in an easy way.
Just set the initial value (the type will be inferred based on this value)
and you have it!
// - store-example.ts
import { cervello } from '@cervello/react'
export const {
store, // Reactive store object
useStore, // Hook to listen for store changes
useSelector, // Hook to listen for changes on parts of the store
reset, // Function to reset the store to initial value
} = cervello({
count: 0,
isModalOpen: false,
/* ... */
})
// With the store object you can use it outside of React components
const increment = () => { store.count++ }
const Button = () => {
const { count } = useStore() // Listen for changes on the whole store
return (
<button onClick={increment}>
{count}
</button>
)
}
const ButtonWithSelector = () => {
const { count } = useSelector(['count']) // Listen for changes just on 'count' property
return (
<button onClick={increment}>
{count}
</button>
)
}
To see more in depth explanations or API references and more examples: π Documentation website
Created with Typescript! β‘ and latin music πΊπ΅
2.0.3
1 month ago
2.0.2
6 months ago
2.0.1
6 months ago
2.0.0
6 months ago
1.2.0
1 year ago
1.2.1
1 year ago
1.1.0
1 year ago
1.0.2
1 year ago
1.0.1
1 year ago
1.0.0
1 year ago
1.0.6
1 year ago
1.0.5
1 year ago
1.0.4
1 year ago
1.0.3
1 year ago
0.11.8
2 years ago
0.11.0
2 years ago
0.12.0
2 years ago
0.11.1
2 years ago
0.11.2
2 years ago
0.10.3
2 years ago
0.12.2
2 years ago
0.11.3
2 years ago
0.10.4
2 years ago
0.11.4
2 years ago
0.11.5
2 years ago
0.11.6
2 years ago
0.11.7
2 years ago
0.10.2
2 years ago
0.10.1
2 years ago
0.10.0
2 years ago
0.9.6
2 years ago
0.9.5
2 years ago
0.9.4
2 years ago
0.9.3
2 years ago
0.9.2
2 years ago
0.9.1
2 years ago
0.9.0
2 years ago