Skip to content

Instantly share code, notes, and snippets.

@stenin-nikita
Last active April 3, 2020 16:13
Show Gist options
  • Save stenin-nikita/72e8beb151dcb4276783e6ad20f5dc6e to your computer and use it in GitHub Desktop.
Save stenin-nikita/72e8beb151dcb4276783e6ad20f5dc6e to your computer and use it in GitHub Desktop.
import { useContext, useEffect } from 'react';
import { context } from '@reatom/react';
export function useActionEffect(actionCreator, callback) {
const store = useContext(context);
useEffect(() => store.subscribe(actionCreator, () => callback()), [store, callback]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment