@asoft-ltd/viewmodel-react
TypeScript icon, indicating that this package has built-in type declarations

0.0.10 • Public • Published

Live React

badge badge badge badge badge badge

Introduction

Built on top of Live, this extension will get you a react hook that follows Live<T> and updates it's value when the value of Live<T> changes

Setup

npm install @asoft-ltd/live-react

Samples

Step 1: get the useLive hook

import { Live, useLive } from "@asoft-ltd/live-react"

const live = new Live(1)

interface CounterProps {
  onToggle: () => void
}

function Counter(props: CounterProps) {
  const value = useLive(live)
  return (
    <div className="App">Live Value: {value}</div>
  );
}

Note:

Since Live<S> should only be used in presentational layers and it's main purpose is to just change state for ui, useLive doesn't provide the mechanism to update the state.

Readme

Keywords

Package Sidebar

Install

npm i @asoft-ltd/viewmodel-react

Weekly Downloads

1

Version

0.0.10

License

MIT

Unpacked Size

10.2 kB

Total Files

8

Last publish

Collaborators

  • andylamax