Expose isSavingEntityRecord
and isDeletingEntityRecord
when using useEntityRecord
#56471
Open
Description
opened on Nov 23, 2023
What problem does this address?
Currently useEntityRecord
exposes almost all of the actions / info you might need relating to the entity record, such as record
, save
, edit
, isResolving
, hasResolved
etc, but to find out if a save
is in progress (to show loaders for example), we have to make a seperate select
call with the same paramaters to find out if its saving.
The navigation menu is doing it here:
const { record: navigationMenu, isResolving } = useEntityRecord(
'postType',
postType,
postId
);
const { isSaving, isDeleting } = useSelect(
( select ) => {
const { isSavingEntityRecord, isDeletingEntityRecord } =
select( coreStore );
return {
isSaving: isSavingEntityRecord( 'postType', postType, postId ),
isDeleting: isDeletingEntityRecord(
'postType',
postType,
postId
),
};
},
[ postId ]
);
What is your proposed solution?
It would be nice if useEntityRecord
also exposed isSavingEntityRecord
and isDeletingEntityRecord
as something like isSaving
and isDeleting
.
Assuming useEntityRecord
is supposed to be an easy way to access actions and data about an entity record, then it seems these are the last two pieces of information missing.
Activity