Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antd: SSR TypeError: Cannot read properties of null (reading 'useContext') #505

Closed
ahuigo opened this issue Aug 14, 2022 · 4 comments
Closed

Comments

@ahuigo
Copy link

ahuigo commented Aug 14, 2022

I want to use alephjs with antd, but I'm getting some errors that I couldn't solve with Google.

Version

aleph 1.0.0-beta.1

Reproduced code

// routes/index.tsx
import { Button } from "https://esm.sh/antd?bundle"
export default function Index() {
  return (
     <Button>test</Button> 
  );
}

Error

Download https://localhost:3000/routes/index.tsx?ssr&v=l6tfyysf
ERROR SSR TypeError: Cannot read properties of null (reading 'useContext')
    at Module.n.useContext (https://esm.sh/v91/[email protected]/deno/react.js:2:6128)
    at ice (https://esm.sh/v91/[email protected]/deno/antd.bundle.js:102:5879)
    at Zn (https://esm.sh/v87/[email protected]/deno/server.js:12:11816)
    at St (https://esm.sh/v87/[email protected]/deno/server.js:12:14166)
    at V (https://esm.sh/v87/[email protected]/deno/server.js:12:14924)
    at xt (https://esm.sh/v87/[email protected]/deno/server.js:12:15890)
    at St (https://esm.sh/v87/[email protected]/deno/server.js:12:12960)
    at V (https://esm.sh/v87/[email protected]/deno/server.js:12:14924)
    at St (https://esm.sh/v87/[email protected]/deno/server.js:12:12782)
    at V (https://esm.sh/v87/[email protected]/deno/server.js:12:14924)
@ahuigo ahuigo changed the title aleph 1.0.0-alpha.78+antd: SSR TypeError: Cannot read properties of null (reading 'useContext') antd: SSR TypeError: Cannot read properties of null (reading 'useContext') Aug 14, 2022
@ahuigo
Copy link
Author

ahuigo commented Aug 14, 2022

There are some compatible problem with antd.

If I have time, I plan to migrate the antd's base component to deno platform:
https://github.com/react-component

@ije
Copy link
Member

ije commented Aug 15, 2022

this is a cache problem, try deno run -r -A server.ts

@ahuigo
Copy link
Author

ahuigo commented Aug 15, 2022

this is a cache problem, try deno run -r -A server.ts

Other problems arise.

It seems that esm.sh has conversion error which break the generation of window.__ROUTE_MODULES
https://esm.sh/v91/[email protected]/es2022/antd.development.bundle.js

Unexpected token '/' (at antd.development.bundle.js:formatted:39871:30)
import * as React299 from "/"/-/esm.sh/v91/[email protected]/es2022/react.development.js"var FormItemInput = function FormItemInput2(props) {

image

@ahuigo
Copy link
Author

ahuigo commented Aug 16, 2022

This problem may be caused by server/transformer.ts.

When I debug my code and step into transformer.ts via deno run -A --inspect --inspect-brk.

Another error was thrown in this code:
https://github.com/alephjs/aleph-compiler/blob/main/dist/compiler.js#L221

return await WebAssembly.instantiateStreaming(module, imports);
// 'TypeError: WebAssembly.compile(): Argument 0 must be a buffer source'

image

I'm having a bit of a problem about debugging: denoland/vscode_deno#708

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants