useActiveProfile
useActiveProfile
is a React Hook that lets you access the currently active Profile.
const { data, loading } = useActiveProfile();
Usage
An Signer
can own multiple Lens profiles. The Lens SDK has the concept of Active Profile. It's an in memory reference to a Profile object owned by the logged-in Signer
. It is also persisted in the underlying IStorageProvider
(see LensConfig
until log out.
Call useActiveProfile
whenever you need access to the active Profile data.
import { useActiveProfile } from '@lens-protocol/react';
function ActiveProfileHandle() {
const { data, loading } = useActiveProfile();
if (loading) return <p>Loading...</p>
if (data === null) return <p>No active profile selected</p>
return <p>@{data.handle}</p>
}
Which profile?
During the login the first profile owned by the authenticated
Signer
will be selected as the active profile.
Reference
useActiveProfile()
useActiveProfile()
function ActiveProfileHandle() {
const { data, loading } = useActiveProfile();
// ...
}
Parameters
useActiveProfile
does not take any parameters.
Returns
data
the Profile data ornull
if there is no active profile.loading
a flag that let you determine ifdata
is ready to be read.
Updated 11 days ago