import { React } from '@gravityforms/libraries';
import { uniqueId } from '@gravityforms/utils';
const { useState } = React;
/**
* @function useId
* @description Generates a unique ID if default ID is not provided.
*
* @since 3.2.2
*
* @param {string} defaultId The default ID.
*
* @return {string} The ID.
*/
const useId = ( defaultId ) => {
const [ id ] = useState( () => defaultId || uniqueId( 'id' ) );
return defaultId || id;
};
export default useId;