useGetIdentity

You may want to use the current user name, avatar, or id in your code. for that purpose, call the useGetIdentity() hook, which calls authProvider.getIdentity() on mount. It returns an object containing the loading state, the error state, and the identity.

Here is an example Edit component, which falls back to a Show component if the record is locked for edition by another user:

import { useGetIdentity, useGetOne } from 'react-admin';

const PostDetail = ({ id }) => {
    const { data: post, isLoading: postLoading } = useGetOne('posts', { id });
    const { identity, isLoading: identityLoading } = useGetIdentity();
    if (postLoading || identityLoading) return <>Loading...</>;
    if (!post.lockedBy || post.lockedBy === identity.id) {
        // post isn't locked, or is locked by me
        return <PostEdit post={post} />
    } else {
        // post is locked by someone else and cannot be edited
        return <PostShow post={post} />
    }
}