You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

пре 3 година
123456789101112131415161718192021222324
  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;