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

Cannot read properties of undefined (reading '__H') in Deno Fresh #2

Open
omar2205 opened this issue Jul 31, 2022 · 4 comments
Open

Comments

@omar2205
Copy link

I'm trying to use this in Deno Fresh

TypeError: Cannot read properties of undefined (reading '__H')
    at f (https://esm.sh/v89/preact@10.10.0/deno/hooks.js:2:186)
    at D (https://esm.sh/v89/preact@10.10.0/deno/hooks.js:2:320)
    at q (https://esm.sh/v89/preact@10.10.0/deno/hooks.js:2:289)
    at p (https://esm.sh/v89/@nanostores/preact@0.2.0/deno/preact.js:2:174)
    at Object.default (file:///[REDACTED]/islands/ProjectSources.tsx:54:13)
    at h (https://esm.sh/v87/preact-render-to-string@5.2.0/X-ZC9wcmVhY3RAMTAuOC4y/deno/preact-render-to-string.js:4:1003)
    at h (https://esm.sh/v87/preact-render-to-string@5.2.0/X-ZC9wcmVhY3RAMTAuOC4y/deno/preact-render-to-string.js:9:66)
    at h (https://esm.sh/v87/preact-render-to-string@5.2.0/X-ZC9wcmVhY3RAMTAuOC4y/deno/preact-render-to-string.js:4:1103)
    at h (https://esm.sh/v87/preact-render-to-string@5.2.0/X-ZC9wcmVhY3RAMTAuOC4y/deno/preact-render-to-string.js:4:7)
    at h (https://esm.sh/v87/preact-render-to-string@5.2.0/X-ZC9wcmVhY3RAMTAuOC4y/deno/preact-render-to-string.js:4:190)
@ai
Copy link
Member

ai commented Jul 31, 2022

Sorry, I am not Deno Fresh user and I will need help with this issue. Please send PR if you will find the source.

@omar2205
Copy link
Author

omar2205 commented Aug 1, 2022

Not sure what the problem is. I tried writing the hook myself, and it worked without problems. But, if I use this package, it breaks.

import { listenKeys } from 'nanostores'
function useStore(store, opts = {}) {
  let [, forceRerender] = useState({})
  useEffect(() => {
    let batching: number|undefined, timer, unlisten

    let rerender = () => {
      if(!batching) {
        batching = 1
        timer = setTimeout(() => {
          batching = undefined
          forceRerender({})
        })
      }
    }
    if(opts.keys) {
      unlisten = listenKeys(store, opts.keys, rerender)
    } else {
      unlisten = store.listen(rerender)
    }

    return () => {
      unlisten()
      clearTimeout(timer)
    }
  }, [store, '' + opts.keys])

  return store.get()
}

@Casedy
Copy link

Casedy commented Aug 2, 2022

Same trouble with my integration. Copy paste code to local codebase (as above) works well.

@distolma
Copy link

distolma commented Feb 7, 2023

Importing preact-render-to-string with an external query parameter works for me. "preact-render-to-string": "https://esm.sh/preact-render-to-string@5.2.6?external=preact"

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

4 participants