livestate

1.1.2 • Public • Published

livestate

livestate.io client

NPM JavaScript Style Guide

Install

npm install --save livestate

Usage

import { useLiveState, LiveStateProvider } from 'livestate'

const App = () => (
  <LiveStateProvider uri='wss://try.livestate.io/socket'>
    <CounterExample />
  </LiveStateProvider>
)

const counterId = 'the-universal-global-counter-id'
const CounterExample = () => {
  const [state, setState] = useLiveState({
    id: counterId,
    defaultValue: { counter: 0 }
  })

  return (
    <div>
      <button onClick={() => setState({ counter: state.counter + 1 })}>
        Increment
      </button>
      <p>Counter: {state.counter}</p>
    </div>
  )
}

License

MIT © webdeb

/livestate/

    Package Sidebar

    Install

    npm i livestate

    Weekly Downloads

    1

    Version

    1.1.2

    License

    MIT

    Unpacked Size

    34 kB

    Total Files

    7

    Last publish

    Collaborators

    • webdeb