5.2.0 β€’ Published 6 months ago

@cervello/react v5.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

Cervello

npm version bundle-size

🀯 Simple, reactive, tiny and performant state-management library for React (just 1.5kb)

πŸš€ Features

  • βš›οΈ 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

πŸ“¦ Install

# NPM
npm install @cervello/react

# PNPM
pnpm add @cervello/react

# YARN
yarn add @cervello/react

πŸ’» Quick Usage

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.

// - store-example.ts
import { cervello } from '@cervello/react'

export const {
  store,       // Object with reactive changes
  useStore,    // Hook to listen for store or partial store changes
  reset,       // Function to reset the store to initial value
} = 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>)
}


// Just listen for changes in the `city` property
const AddressWithSelector = () => {
  const { address } = useStore({
    select: ['address.city']
  })

  return (<p>City: {address.city}</p>)
}

To see more in depth explanations or API references and more examples: πŸ“– Documentation website


Created with Typescript! ⚑ and latin music 🎺🎡

5.1.0

7 months ago

5.0.0-beta.8

7 months ago

5.0.0-beta.9

7 months ago

5.0.0-beta.6

7 months ago

5.0.0-beta.7

7 months ago

5.0.0-beta.4

7 months ago

5.0.0-beta.5

7 months ago

5.0.0-beta.2

8 months ago

5.0.0-beta.3

7 months ago

5.0.0-beta.1

8 months ago

5.0.0-beta.11

7 months ago

5.0.0-beta.10

7 months ago

5.2.0

6 months ago

5.0.0

7 months ago

5.2.0-beta.0

6 months ago

5.1.0-beta.1

7 months ago

5.1.0-beta.2

7 months ago

5.1.0-beta.7

7 months ago

5.1.0-beta.8

7 months ago

5.1.0-beta.9

7 months ago

5.1.0-beta.3

7 months ago

5.1.0-beta.4

7 months ago

5.1.0-beta.5

7 months ago

5.1.0-beta.6

7 months ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.2.0

3 years ago

1.2.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

0.11.8

3 years ago

0.11.0

3 years ago

0.12.0

3 years ago

0.11.1

3 years ago

0.11.2

3 years ago

0.10.3

3 years ago

0.12.2

3 years ago

0.11.3

3 years ago

0.10.4

3 years ago

0.11.4

3 years ago

0.11.5

3 years ago

0.11.6

3 years ago

0.11.7

3 years ago

0.10.2

3 years ago

0.10.1

3 years ago

0.10.0

3 years ago

0.9.6

3 years ago

0.9.5

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago