mirror of
https://github.com/t4t5/nostr-react.git
synced 2025-12-06 02:32:19 +01:00
Document "useProfile" hook
This commit is contained in:
20
README.md
20
README.md
@@ -86,6 +86,26 @@ const ProfileFeed = () => {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
**Fetching user profiles**
|
||||||
|
|
||||||
|
Use the `useProfile` hook to render user profiles. You can use this in multiple components at once (for example, rendering a name and avatar for each message in a chat), the hook will automatically use *batching* to prevent errors where a client sends too many requests at once. 🎉
|
||||||
|
|
||||||
|
```tsx
|
||||||
|
const Profile = () => {
|
||||||
|
const userData = useProfile({
|
||||||
|
pubkey,
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<p>Name: userData?.name</p>
|
||||||
|
<p>Public key: userData?.npub</p>
|
||||||
|
<p>Picture URL: userData?.avatarUrl</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
**Post a message:**
|
**Post a message:**
|
||||||
|
|
||||||
```tsx
|
```tsx
|
||||||
|
|||||||
Reference in New Issue
Block a user