Open ezekielchentnik opened 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; }
already exist https://github.com/Andarist/use-callbag