1.0.0-alpha.1 • Published 2 years ago

@actorize/react v1.0.0-alpha.1

Weekly downloads
12
License
MIT
Repository
github
Last release
2 years ago

@actorize/react

gzip size

this is just the React Extension for @actorize/core

Getting Started

$ npm install @actorize/react
# or
$ yarn add @actorize/react
import { ActorizeProvider, useActorize } from '@actorize/react';
import {
  dispatch
} from '@actorize/core';
import director from './director';
// ...

const MyCoolActor = () => {
  const [state, setState] = useSate(0)

  const actor = useActorize('cool-actor', {
    onMessage: (msg) => {
      if (msg.payload === 'INC') {
        setState(state + 1)
      }
    },
  });

  return (
    <div>
      {state}
    </div>
  )
}

const ThatBigButton = () => {
  const handleClick = () => {
    dispatch(director, 'cool-actor', 'INC');
  }
  return (
    <button onClick={handleClick} >Click Me</button>
  )
}

const Wrapper = () => (
  <ActorizeProvider director={director}>
    <MyCoolActor />
    <ThatBigButton />
  </ActorizeProvider>
)
1.0.0-alpha.1

2 years ago

1.0.0

3 years ago

0.0.7

3 years ago

0.0.6

3 years ago

0.0.5

3 years ago

0.0.3

3 years ago

0.0.2

3 years ago

0.0.4

3 years ago

0.0.1

3 years ago