Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
import { useRef } from "react";
import { type EffectCallback, useEffect } from "react";
export const useMount = (effect: EffectCallback) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
useEffect(effect, []);
};
export const useUnmount = (fn: () => void): void => {
const fnRef = useRef(fn);
// update the ref each render so if it change the newest callback will be invoked
fnRef.current = fn;
useMount(() => {
return () => fnRef.current();
});
};