Added onViewChanged to React Auth UI so that view can be externally synchronized #260
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
This introduces a feature where you can pass a callback
onViewChanged
to theAuth
component for React. This callback gets executed, whenever the view of the Auth UI changes so that you can externally synchronize with it.My specific use-case of it was that I wanted to synchronize the
redirectUrl
with whatever view a user selected. For example on sign up I want to redirect to[main app URL]/onboarding
while on the forgotten password page I want to redirect to[main app URL]/reset-password
.This could also potentially help with #236 and #223
Also remember that the
redirectUrl
needs to match the redirect URL settings on Supabase.What is the current behavior?
When a view is selected, that state is isolated to the Auth UI component. You can pass the initial view, but cannot listen to changes.
What is the new behavior?
See feature description above;
onViewChanged
gets called by Auth UI component whenever the view changes.Additional context
Example of how I use this new feature: