Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

24 righe
494 B

  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. function useMountEffect(effect) {
  20. return useEffect(effect, []);
  21. }
  22. export default useMountEffect;