scaffold-eth / scaffold-eth-2

Open source forkable Ethereum dev stack
https://scaffoldeth.io
MIT License
1.34k stars 837 forks source link

Update useScaffoldEventHistory hook #827

Closed rin-st closed 5 months ago

rin-st commented 5 months ago

Description

  1. Moved readEvents to useCallback, so it's clear which dependencies it has
  2. Since fromBlock is required prop, removed if's like if (fromBlock)
  3. Combined two useEffects with the same functionality readEvents(); and
    if (!deployedContractLoading) {
    readEvents();
    }

    The one without if (!deployedContractLoading) was buggy - on load it threw errors to the console

  4. Changed default state of events to [], so we don't guess is it array or undefined

Additional Information

rin-st commented 5 months ago

Thanks! Merging this