slurppy
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-b2 • Public • Published

slurppy

Simple reactive array db for react.

Usage

import { useDispatcher, useSlurp, SlurpProvider } from 'slurppy'

const App = () => {
  const { state, updated } = useSlurp()
  const { insert, reset } = useDispatcher()

  const addItem = () => {
    insert({ new: 'another' })
  }

  return (
    <SlurpProvider initialData={[{ hello: 123 }]} autoRead autoWrite>
      <div>
        {JSON.stringify(state)}

        {JSON.stringify(window.localStorage.getItem('slurpdb'))}

        <button onClick={addItem}>add new item</button>
        <button onClick={reset}>remove all</button>
      </div>
    </SlurpProvider>
  )
}

export default App

© 2021 | License

Dependencies (2)

Dev Dependencies (33)

Package Sidebar

Install

npm i slurppy

Weekly Downloads

0

Version

0.0.1-b2

License

ISC

Unpacked Size

36.8 kB

Total Files

17

Last publish

Collaborators

  • theboringdude