Preact X and hooks
See original GitHub issueHi.
I’ve installed the default template from the latest preact-cli.
I’ve followed the migration guide and I’ve updated preact, preact-router and preact-render-to-string using the @next
version.
I can run the preact-cli project without any problem. I can try the import { useState } from 'preact/hooks'
and it works fine.
The problem is when I try to import a library I made for state management, that is using Hooks (via import { useState } from 'react'
. Since Preact X already comes with preact-compat I don’t think its an alias issue but preact doesnt correctly map { useState } from 'react'
to { useState } from 'preact/hooks'
I get the following error:
‼ WARN ./node_modules/snap-state/dist/snap-state.module.js
12:13-14 "export 'useState' (imported as 'n') was not found in 'react'
@ ./node_modules/snap-state/dist/snap-state.module.js
@ ./src/components/app.js
@ ./src/index.js
@ ./node_modules/preact-cli/lib/lib/entry.js
@ multi ./node_modules/preact-cli/lib/lib/entry webpack-dev-server/client webpack/hot/dev-server
‼ WARN ./node_modules/snap-state/dist/snap-state.module.js
16:10-11 "export 'useEffect' (imported as 't') was not found in 'react'
@ ./node_modules/snap-state/dist/snap-state.module.js
@ ./src/components/app.js
@ ./src/index.js
@ ./node_modules/preact-cli/lib/lib/entry.js
@ multi ./node_modules/preact-cli/lib/lib/entry webpack-dev-server/client webpack/hot/dev-server
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Hooks | Preact: Fast 3kb React alternative with the same ES6 ...
Hooks is a new concept that allows you to compose state and side effects. They allow you to reuse stateful logic between components....
Read more >What's new in Preact X
New features and changes in Preact X. ... Fragments; componentDidCatch; Hooks; createContext; CSS Custom Properties; Compat lives in core ...
Read more >Option Hooks | Preact: Fast 3kb React alternative with the ...
Preact supports a number of different callbacks that can be used to observe or change each stage of the rendering process, commonly referred...
Read more >Upgrading from Preact 8.x
Preact X brings many new exciting features such as Fragments , hooks and much improved compatibility with the React ecosystem. We tried to...
Read more >Components | Preact
Components represent the basic building block in Preact. They are fundamental in making it easy to ... This doesn't hold true anymore with...
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
@andrevenancio the default template installs an older version of
preact-cli
local to the project. You need to update that too (npm i -D preact-cli@rc
).Oh I see. Alright, I’ll have a look at it, massive thanks for the help.
I’ll use this for now, and then hopefully when PreactX comes up preact-cli will also be out and about and all will look great.
Massive thanks for this, and maintaining the libraries. Both of you! ❤️