Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 

41 строка
924 B

  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _react = require("react");
  5. /**
  6. * Runs an effect only when the dependencies have changed, skipping the
  7. * initial "on mount" run. Caution, if the dependency list never changes,
  8. * the effect is **never run**
  9. *
  10. * ```ts
  11. * const ref = useRef<HTMLInput>(null);
  12. *
  13. * // focuses an element only if the focus changes, and not on mount
  14. * useUpdateEffect(() => {
  15. * const element = ref.current?.children[focusedIdx] as HTMLElement
  16. *
  17. * element?.focus()
  18. *
  19. * }, [focusedIndex])
  20. * ```
  21. * @param effect An effect to run on mount
  22. *
  23. * @category effects
  24. */
  25. function useUpdateEffect(fn, deps) {
  26. var isFirst = (0, _react.useRef)(true);
  27. (0, _react.useEffect)(function () {
  28. if (isFirst.current) {
  29. isFirst.current = false;
  30. return;
  31. }
  32. return fn();
  33. }, deps);
  34. }
  35. var _default = useUpdateEffect;
  36. exports.default = _default;