scaffold-eth-2 icon indicating copy to clipboard operation
scaffold-eth-2 copied to clipboard

useScaffoldEventHistory uses data from old fetch with different filters

Open phaitonican opened this issue 6 months ago • 2 comments

Is there an existing issue for this?

Which method was used to setup Scaffold-ETH 2 ?

git clone

Current Behavior

I use useScaffoldEventHistory twice on a single page with different filters. It fetches right data. I run again and the old data does not change, it use overrides the data with first run of useScaffoldEventHistory (even the constants have a differnt name). Any ideas??

This:

<PostCardList key="-1" filters={{ _post_hash: postHash }} />
<PostCardList key="-2" filters={{ _parent_post_hash: postHash }} />

and PostCardList.tsx:

export const PostCardList = ({ filters }: PostCardListProps) => {

const { data: postCreatedEvents, isLoading } = useScaffoldEventHistory({
    contractName: "PostCreator",
    eventName: "PostCreated",
    fromBlock: 0n,
    watch: true,
    filters: filters 
  });
...

But the second One gets overridden with contents of first one?? Both solidity parameters are indexed. And I also put a key inside my looped list items (unique hash)

Expected Behavior

No response

Steps To Reproduce

Use useScaffoldEventHistory on same page with different filters

Anything else?

No response

phaitonican avatar Aug 02 '24 17:08 phaitonican