Skip to content

Commit

Permalink
Add inline comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jun 20, 2024
1 parent 6c5949b commit a27a173
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/editor/src/components/post-actions/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,12 @@ const trashPostAction = {

function useTrashPostAction( postType ) {
const registry = useRegistry();
const { resource, canUserResolvers } = useSelect(
const { resource, cachedCanUserResolvers } = useSelect(
( select ) => {
const { getPostType, getCachedResolvers } = select( coreStore );
return {
resource: getPostType( postType )?.rest_base || '',
canUserResolvers: getCachedResolvers().canUser,
cachedCanUserResolvers: getCachedResolvers().canUser,
};
},
[ postType ]
Expand All @@ -331,8 +331,10 @@ function useTrashPostAction( postType ) {
);
},
} ),
// We are making this use memo depend on cachedCanUserResolvers as a way to make the component using this hook re-render
// when user capabilities are resolved. This makes sure the isEligible function is re-evaluated.
// eslint-disable-next-line react-hooks/exhaustive-deps
[ registry, resource, canUserResolvers ]
[ registry, resource, cachedCanUserResolvers ]
);
}

Expand Down

0 comments on commit a27a173

Please sign in to comment.