0.0.9 • Published 1 year ago

@-ft/watch-target-react v0.0.9

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

watch-target-react - Util watchTarget wrapper for React

React wrapper of util watchTarget

Usage

function Portal({ children }) {
  const { addComponent } = useContext(PortalContext);
  const childrenWatchTarget = useLayoutWatchTarget(children);
  useEffect(
    () => addComponent(toComponent(childrenWatchTarget.watch)),
    [addComponent]
  );
  return null;
}

function toComponent(childrenWatchTarget) {
  return function Component() {
    return <>{useWatchValue(childrenWatchTarget)}</>;
  };
}
0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

2 years ago