alephjs / aleph.js

The Full-stack Framework in Deno.

Home Page:https://alephjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

omar2205 opened this issue · comments

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
commented

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

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)
  }, [])
commented

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

commented

ea32ee2 fixed this cache issue

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

commented

Screenshot 2023-03-27 at 03 08 31

seems it works for me
commented

Cannot read properties of null (reading 'useState')

where you got the message? is devtools console?

Are you running deno task start?

image

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