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

SSR TypeError: Cannot read properties of null (reading 'useState') #549

Closed
omar2205 opened this issue Mar 26, 2023 · 9 comments
Closed

SSR TypeError: Cannot read properties of null (reading 'useState') #549

omar2205 opened this issue Mar 26, 2023 · 9 comments

Comments

@omar2205
Copy link

I'm trying to use deno task start but it's failing.

Steps:

  1. Run deno run -A -r https://alephjs.org/init.ts
  2. Choose React, and yes to all
  3. Run deno task start
  4. You get greeted with this
    image
@ije
Copy link
Member

ije commented Mar 26, 2023

try to execute deno cache -r https://esm.sh/react@18.2.0

@omar2205
Copy link
Author

It fixed the generated template. Now when I try to add this code it breaks again with

Cannot read properties of null (reading 'useState')
import { useEffect, useState } from "react"
// ...

  const [c, setC] = useState(0)

  useEffect(() => {
    const i = setInterval(() => {
      setC(c + 1);
    }, 500)
    return () => clearInterval(i)
  }, [])

@ije
Copy link
Member

ije commented Mar 26, 2023

please change "react": "https://esm.sh/react@18.2.0" to "react": "https://esm.sh/v113/react@18.2.0" in your import map and jsxImportSource in deno.json

@ije ije closed this as completed in ea32ee2 Mar 26, 2023
@ije ije reopened this Mar 26, 2023
@ije
Copy link
Member

ije commented Mar 26, 2023

ea32ee2 fixed this cache issue

@omar2205
Copy link
Author

omar2205 commented Mar 26, 2023

mmm, I updated that import but still.
Here is a repo with the problem https://github.com/omar2205/aleph-q-react

@ije
Copy link
Member

ije commented Mar 26, 2023

Screenshot 2023-03-27 at 03 08 31

seems it works for me

@ije
Copy link
Member

ije commented Mar 26, 2023

Cannot read properties of null (reading 'useState')

where you got the message? is devtools console?

@omar2205
Copy link
Author

Are you running deno task start?

image

@omar2205
Copy link
Author

... I had to CTRL+SHIFT+R 🤦

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