All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.utils.use-effect-once.js Maven / Gradle / Ivy

Go to download

A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.

The newest version!
'use client';
import { useRef, useEffect } from 'react';

const useEffectOnce = (cb) => {
  const savedCallback = useRef(cb);
  const effectGuard = useRef(false);
  useEffect(() => {
    savedCallback.current = cb;
  });
  useEffect(() => {
    if (effectGuard.current !== true) {
      effectGuard.current = true;
      savedCallback.current();
    }
  }, []);
};

export { useEffectOnce };




© 2015 - 2025 Weber Informatics LLC | Privacy Policy