Cannot import hooks directly from unpkg
See original GitHub issueHello,
hooks.module.js import from preact
module, causing resolution failure when loading hooks as ES6 module. Should we import from preact.module.js in the same package instead?
This is how I load preact
and preact/hooks
:
import { h, render } from 'https://unpkg.com/preact@10.0.0-rc.3/dist/preact.module.js';
import { useState, useEffect } from 'https://unpkg.com/preact@10.0.0-rc.3/hooks/dist/hooks.module.js';
Issue Analytics
- State:
- Created 4 years ago
- Comments:11 (3 by maintainers)
Top Results From Across the Web
How to use useState hook with Preact and no build tools?
Use already resolved URLs for each module (notice the @latest in the preact import). import { h, render } from 'https://unpkg.com/preact@latest?
Read more >readme.md - UNPKG
For example, using a CDN: ```js import ky from ... Type: `Function[]`<br> Default: `[]` This hook enables you to modify the request right...
Read more >react-hot-loader/README.md - UNPKG
Hooks would be auto updated on HMR if they _should_ be. 66, There is only one condition for it - a non zero...
Read more >testing-library/react-hooks - UNPKG
1, import { ReactHooksRenderer } from './types/react'. 2. 3, const renderers = [. 4, { required: 'react-test-renderer', renderer: './native/pure' },.
Read more >ng-lazyload-image/CHANGELOG.md - UNPKG
7, - In some cases users are facing the error: "useClass cannot be undefined". ... 15, import { LazyLoadImageModule, IntersectionObserverHooks, ...
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
Hi there! You can use the following imports to load hooks from unpkg successfully:
It’s important to note that subpackage versioning does not work on unpkg. This is something I’d like to fix but haven’t had the time to do.
Working example: https://codepen.io/developit/pen/XWrvXvo?editors=0010
Hi @jgoux. Importing just the 3 modules from unpkg seems to work fine for me: example.