UNPKG

493 BJavaScriptView Raw
1import { useEffect } from 'react';
2
3/**
4 * Run's an effect on mount, and is cleaned up on unmount. Generally
5 * useful for interop with non-react plugins or components
6 *
7 * ```ts
8 * useMountEffect(() => {
9 * const plugin = $.myPlugin(ref.current)
10 *
11 * return () => {
12 * plugin.destroy()
13 * }
14 * })
15 * ```
16 * @param effect An effect to run on mount
17 *
18 * @category effects
19 */
20function useMountEffect(effect) {
21 return useEffect(effect, []);
22}
23export default useMountEffect;
\No newline at end of file