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