mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-24 09:18:37 +02:00
fix(jazz-auth): wait until clerk is loaded then pass to jazz
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { createJazzReactApp } from "jazz-react"
|
import { createJazzReactApp } from "jazz-react"
|
||||||
import { LaAccount } from "@/lib/schema"
|
import { LaAccount } from "@/lib/schema"
|
||||||
import { useClerk } from "@clerk/nextjs"
|
import { useAuth, useClerk } from "@clerk/nextjs"
|
||||||
import { useJazzClerkAuth } from "jazz-react-auth-clerk"
|
import { useJazzClerkAuth } from "jazz-react-auth-clerk"
|
||||||
|
|
||||||
const Jazz = createJazzReactApp({
|
const Jazz = createJazzReactApp({
|
||||||
@@ -13,17 +13,19 @@ export const { useAccount, useAccountOrGuest, useCoState, useAcceptInvite } = Ja
|
|||||||
|
|
||||||
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
export function JazzAndAuth({ children }: { children: React.ReactNode }) {
|
||||||
const clerk = useClerk()
|
const clerk = useClerk()
|
||||||
|
const { isLoaded } = useAuth()
|
||||||
|
const [authMethod, state] = useJazzClerkAuth(clerk)
|
||||||
|
|
||||||
const [auth, state] = useJazzClerkAuth(clerk)
|
if (!isLoaded) return null
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{state.errors.map((error) => (
|
{state.errors.map(error => (
|
||||||
<div key={error}>{error}</div>
|
<div key={error}>{error}</div>
|
||||||
))}
|
))}
|
||||||
<Jazz.Provider auth={auth || "guest"} peer="wss://mesh.jazz.tools/?key=example@gmail.com">
|
<Jazz.Provider auth={authMethod || "guest"} peer="wss://mesh.jazz.tools/?key=example@gmail.com">
|
||||||
{children}
|
{children}
|
||||||
</Jazz.Provider>
|
</Jazz.Provider>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user