t4t5 / nostr-react

React Hooks for Nostr 🦤
MIT License
86 stars 14 forks source link

Repeated queries get different results #10

Open chmac opened 1 year ago

chmac commented 1 year ago

I'm using useProfile() and useNostrEvents(). I have a component to render profiles. It is called for the same user multiple times. But only 1 of the components gets either a profile or an event. The other components gets an empty array for .events.

Here's what I mean in pseudocode...

export const Profile = ({id}:{id: string}) => {
  const profileResult = useProfile({pubkey: id})
  return <div>{JSON.parse(profileResult)}</div>
}

export const Example = () => {
  <React.Fragment>
    <Profile
      id={"3e5dc1f1ed0ad1bd24055da9588a69d37d6eb983526c0fb12aff31199ed8f4b0"}
    />
    <Profile
      id={"3e5dc1f1ed0ad1bd24055da9588a69d37d6eb983526c0fb12aff31199ed8f4b0"}
    />
  </React.Fragment>;
};

In this example, the second component gets the profile, but the first gets undefined.

I tried swapping useProfile() for useNostrEvents() and constructing the query manually, but I get the same result.