rehooks / ideas

Got an idea for a new React Hook for this org, start here
110 stars 1 forks source link

useCallbag #47

Open ezekielchentnik opened 6 years ago

ezekielchentnik commented 6 years ago
import subscribe from 'callbag-subscribe';
import { useEffect, useState } from 'react';

export default function useCallbag(factory) {
  const [state, setState] = useState();
  useEffect(() => subscribe(setState)(factory()), []);
  return state;
}
jeetiss commented 6 years ago

already exist https://github.com/Andarist/use-callbag