Skip to content

onAfterEmailVerified hook called twice in development #3407

@infomiho

Description

@infomiho

The onAfterEmailVerified hook is being triggered twice in development mode when using Wasp's <VerifyEmailForm /> component, causing duplicate operations (e.g., welcome emails being sent twice).

Technically this isn't a bug but expected behaviour: React 18's Strict Mode renders components twice in development to check if components are doing their cleanup correctly. Since <VerifyEmailForm /> triggers the verification backend endpoint as soon as it's mounted, this results in the request being sent twice in development.

But it's unexpected for users and they might think it will happen in production.

Proposed solution

Implement a similar workaround as was done for the OAuth component to prevent the backend from being triggered twice in development mode.

Based on https://discord.com/channels/686873244791210014/1438285961225044039/1441432541402763446

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingf: auth

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions