React: Optionally treat loading as unauthenticated #203
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.
Hey all, I used convex for some weeks now and came across the
<Unauthenticated />
react component.I noticed when using SSR in NextJS there is a short time window where the page renders nothing when using said component together with
<Authenticated />
. I looked into the code and found out, that when the authentication state is loading, neither of said components render anything.To have more control over this and to fix this small issue I want to introduce a prop on the
<Unauthenticated />
component.How does it work?
With the prop
loadingEqualsUnauthenticated
developers can decide wether they want to treat the loading state as unauthenticated or not. So when this gets set totrue
, the loading state is ignored and the children are rendered to the DOM.This option defaults to
false
, so this should not be a breaking change. This is something similar to what Clerk provides through their built-in components: loadingEqualsUnauthenticatedPlease let me know what you think of this change. Any feedback is welcome.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.