Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update useScaffoldEventHistory hook #827

Merged
merged 3 commits into from
Apr 28, 2024
Merged

Conversation

rin-st
Copy link
Collaborator

@rin-st rin-st commented Apr 25, 2024

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

Copy link
Collaborator

@damianmarti damianmarti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well and the code looks good to me, I only left a small comment.

Thanks!!

Copy link
Collaborator

@Pabl0cks Pabl0cks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job @rin-st!!

Tested it nicely and only found a problem when you pass enabled: false.

  • In the old version you would get 1 Error: Hook disabled everytime it fires the hook (watch: true)
  • In the new version, it keeps spamming the error in the console.

Rest worked great! 🙌

Copy link
Collaborator

@Pabl0cks Pabl0cks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix working great! Thanks for the quick fix! 🙌

@rin-st
Copy link
Collaborator Author

rin-st commented Apr 28, 2024

Thanks! Merging this

@rin-st rin-st merged commit c1ee5b6 into main Apr 28, 2024
1 check passed
@rin-st rin-st deleted the fix-use-scaffold-event-history branch April 28, 2024 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants