UNPKG

@wordpress/core-data

Version:
15 lines (13 loc) 417 B
import { useContext } from '@wordpress/element'; import { EntityContext } from '../entity-context'; /** * Hook that returns the ID for the nearest * provided entity of the specified type. * * @param {string} kind The entity kind. * @param {string} name The entity name. */ export default function useEntityId( kind, name ) { const context = useContext( EntityContext ); return context?.[ kind ]?.[ name ]; }