Saltar al contenido principal

Cervello

๐Ÿคฏ Simplest reactive state manager for React

Cervello is a simple, reactive, tiny and performant state-management library for React

It's as simple as reassign a new value to the store properties.
It will notify all the components using `useStore` hook to re-render with the new value.

  • โš›๏ธ Reactive with store object changes (nested properties too ๐Ÿš€!!)
  • โœ… Simple & minimalistic API
  • ๐Ÿš€ Batched updates and optimized re-renders
  • ๐Ÿจ Lazy listen nested properties
  • ๐Ÿ”’ Immutable changes
  • ๐Ÿ”‘ Typescript support


import { cervello } from '@cervello/react'


export const {
store, // object with reactive changes
useStore, // Hook to be used in the components
reset, // Function to reset the store
} = cervello({
fullName: 'Cervello Store',
address: {
city: 'Huelva',
},
})


// Change value from anywhere
store.address.city = 'Sevilla'


// Listen for changes from components
function Address() {
const { address } = useStore()
return (<p>City: {address.city}</p>)
}