@wordpress/media-utils
Version:
WordPress Media Upload Utils.
22 lines • 1.07 kB
TypeScript
/**
* Hook for invalidating all cached `getEntityRecords` resolutions for the
* attachment post type.
*
* After a file upload completes the media grid needs to refresh, but
* `invalidateResolution` only clears the exact query that is passed to it.
* If the user is on page 2, page 1 (where the new upload would appear) stays
* stale. Using `invalidateResolutionForStoreSelector` would work but is too
* broad — it clears every `getEntityRecords` resolution, potentially
* triggering unnecessary refetches for unrelated entity types.
*
* This hook provides a middle ground: it iterates over every cached
* resolution for `getEntityRecords` and invalidates only the entries where
* the first two arguments match `['postType', 'attachment']`.
*/
/**
* Returns a stable callback that invalidates all cached `getEntityRecords`
* resolutions for `postType / attachment`, leaving every other entity type
* untouched.
*/
export declare function useInvalidateAttachmentResolutions(): () => void;
//# sourceMappingURL=use-invalidate-attachment-resolutions.d.ts.map