0.1.4 • Published 4 years ago

@reismannnr2/react-observable-state-hooks v0.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

react-observable-state-hooks

install

npm install --save @reismannnr2/react-observable-state-hooks

example

import { ObservableState } from '@reismannnr2/observable-state';
import { useChildState$, useCurrentState } from '@reismannnr2/observable-state-hooks';

const ChildComponent = (props) => {
  const text$ = props.text$;
  const [text] = useCurrentState(text$);
  return <button onClick={() => { text$.update('updated') }}>{text}</button>
}
const ParentComponent = () => {
  const state$ = useMemo(() => new ObservableState({ text: 'button', numbers: [1, 2, 3] }), [])
  return <ChildComponent text$={useChildState$(state$, 'text')} />
}
0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago