Cannot read property '__H' of undefined when I try to use mjs-version of the "hooks" package
See original GitHub issueReproduction
Try to import hooks using from the mjs (with no bundlers) as described in the docs:
https://preactjs.com/guide/v8/getting-started/
https://preactjs.com/guide/v10/getting-started/#alternatives-to-jsx
The Preact itself is being imported fine, but I do not understand how should I import the hooks
package properly.
Steps to reproduce
Try to import hooks using mjs
modules format like this
<script type="module">
import {useState} from 'https://unpkg.com/preact@10.4.7/hooks/dist/hooks.mjs?module'
export const useFoo = () => {
const [state, setState] = useState(0);
return {state, setState};
}
</script>
Expected Behavior
Hooks module is imported successfully
Actual Behavior
I see
Cannot read property '__H' of undefined
error in the console and everything crashes (blank page).
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:13 (2 by maintainers)
Top Results From Across the Web
cannot read properties of undefined (reading '__h') - You.com
This works but I'm trying to get hooks to work and I'm running into the issue below. export async function asyncComponentToSync (v: JSX ......
Read more >React hooks Cannot read properties of undefined using react
Any help is greatly appreciated . Uncaught TypeError: Cannot read properties of undefined (reading 'name'). const SignupSchema = yup.object ...
Read more >[accept Hook] - Cannot read property 'toBytesSink' of undefined
Hi, I am learning about Hooks and I wanted to try first with something simple and the "accept" hook. I am using your...
Read more >Cannot read properties of undefined' - JavaScript Debugging
Join Discord https://selftaught-dev.com/join-discord//r/SelfTaughtDev - https://www.reddit.com/r/selftaughtdevGet My Resume Template Free ...
Read more >A Deno Module for Handling Null and Undefined Values
<script type="module"> import { read, writeFileXLSX } from "https://cdn.sheetjs.com/xlsx-0.18.6/package/xlsx.mjs"; /* load the codepage support library for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For future searchers, here is a simple snippet for importing the Preact as the native Ecmascript module:
I developed a simple template (or an example, as you wish). It’s an explanation how to set up skypack CDN’s preact to be used with the Typescript.
The same error. I think this is because hooks.mjs imports latest version of preact for every version. Make an issue #3074