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

META-INF.resources.sxp_blueprint_admin.js.hooks.useDidUpdateEffect.js Maven / Gradle / Ivy

There is a newer version: 3.0.80
Show newest version
/**
 * SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
 * SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
 */

import {useEffect, useRef} from 'react';

/**
 * Hook for calling a function after the first render. Use this the same way
 * as useEffect.
 */
export default function useDidUpdateEffect(fn, inputs) {
	const didMountRef = useRef(false);

	useEffect(() => {
		if (didMountRef.current) {
			fn();
		}
		else {
			didMountRef.current = true;
		}
	}, inputs); //eslint-disable-line
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy