Qwik useState与Supabase Auth组件的错误

huangapple go评论73阅读模式
英文:

Qwik useState Error with Supabase Auth Component

问题

我知道这里没有太多关于Qwik的内容,但我想知道是否有人在根本上理解组件渲染的人可以帮助我解决我的问题。我正在尝试将Supabase Auth UI放入我的component$函数中,如下所示:

import { component$ } from "@builder.io/qwik";
import { createClient } from "@supabase/supabase-js";
import { Auth } from '@supabase/auth-ui-react';

const supabase = createClient(`my-url`, `my-key`);

export default component$(() => {
    return (
        <Auth supabaseClient={supabase} />
    );
})

这会产生以下错误:

内部服务器错误:无法读取 null 的属性(读取 'useState')
文件:/dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:1461:26
在 useState (C:\Users\isaac\Downloads\VS Code\planner\node_modules\react\cjs\react.development.js:1622:21)
在 k (file:///C:/Users/isaac/Downloads/VS%20Code/planner/node_modules/@supabase/auth-ui-react/dist/index.es.js:1211:48)
在 invoke (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:1461:26)
在 renderNode (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4129:17)
在 processData$1 (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4143:16)
在 ../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4210:26
在 Array.reduce (<anonymous>)
在 walkChildren (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4195:21)
在 renderNodeVirtual (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:3688:21)
在 renderNode (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4120:16) (x2)

这是否与延迟加载和组件渲染时的useState表现奇怪有关?

英文:

I know there's not a lot of Qwik content on here, but I was wondering if anyone who fundamentally understands component rendering can help me with my question. I am trying to place a Supabase Auth UI into my component$ function like this:

import { component$ } from &quot;@builder.io/qwik&quot;;

import { createClient } from &quot;@supabase/supabase-js&quot;;
import { Auth } from &#39;@supabase/auth-ui-react&#39;

const supabase = createClient(`my-url`, `my-key`)

export default component$(() =&gt; {
    return (
        &lt;Auth supabaseClient={supabase} /&gt;
    );
})

which produces this error:

Internal server error: Cannot read properties of null (reading &#39;useState&#39;)
  File: /dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:1461:26
      at useState (C:\Users\isaac\Downloads\VS Code\planner\node_modules\react\cjs\react.development.js:1622:21)
      at k (file:///C:/Users/isaac/Downloads/VS%20Code/planner/node_modules/@supabase/auth-ui-react/dist/index.es.js:1211:48)
      at invoke (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:1461:26)
      at renderNode (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4129:17)
      at processData$1 (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4143:16)
      at ../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4210:26
      at Array.reduce (&lt;anonymous&gt;)
      at walkChildren (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4195:21)
      at renderNodeVirtual (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:3688:21)
      at renderNode (../../../dist-dev/tsc-out/packages/qwik/src/core/util/implicit_dollar.js:4120:16) (x2)

Does this have to do with lazy-loading and useState being weird at the time of this component rendering?

答案1

得分: 1

你只能在使用qwikify$()包装React组件之后才能使用React组件。

这里是一个qwik supabase身份验证的工作示例

英文:

you can't use React component without wrapping it with qwikify$()

Here is a qwik supabase auth working example

huangapple
  • 本文由 发表于 2023年6月2日 06:16:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76386060.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定