Hooks not working correctly using off-the-shelf htm@^3.1.0 and preact@^10.5.14
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- javascript
- Ambito
- frontend
Direzione di ricerca
Inizia riproducendo il mount e l’unmount del componente funzionale con htm ^3.1.0 e Preact ^10.5.14, confrontandoli con Preact 10.2.0. Controlla le versioni delle dipendenze in htm e application package.json e gli import di preact/hooks indicati; il lavoro è completato quando l’unmount non genera più un __hooks TypeError usando le versioni previste più recenti.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am using htm and Preact as follows inside a simple functional component. This component is imported by a class component where it is swapped out according to a switching logic with another component. Here is how I am importing the libraries:
import { html } from 'htm/preact';
import { useEffect, useRef, useState } from 'preact/hooks';
I have the latest installed versions of each package. Hooks appear to work fine on first mount, but when the component unmounts, any version of Preact past 10.2.0 is failing with the message TypeError: Cannot read property '__hooks' of undefined. If I install 10.2.0 explicitly then this error goes away. I assume it is because htm has this version in the devDependencies:
"devDependencies": {
"@babel/core": "^7.2.2",
"@babel/preset-env": "^7.1.6",
"@types/jest": "^26.0.24",
"babel-jest": "^24.1.0",
"babel-preset-env": "^1.7.0",
"eslint": "^5.2.0",
"eslint-config-developit": "^1.1.1",
"jest": "^24.1.0",
"microbundle": "^0.10.1",
"preact": "^10.2.0",
"react": "^16.8.3"
}
I think there is a version mismatch happening but I cannot figure out how to fix it. I tried module resolution but that didn't help. My package.json has these dependencies:
"dependencies": {
"htm": "^3.1.0",
"preact": "^10.5.14",
"unfetch": "^4.2.0",
"unistore": "^3.5.2"
}
The combination which works is:
"dependencies": {
"htm": "^3.1.0",
"preact": "10.2.0",
}
Can someone please help me figure this out? Version 10.2.0 came more than a year ago and I would like to use the latest version.
- Lingua principale
- JavaScript
- Stelle
- 9k
- Fork
- 181
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di developit/htm
-
Sarthak Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
-
Tugas Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 10/100
-
Tugas Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
-
type checking templates Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
Tutte le issue di developit/htm
Issue simili
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Improve Title Support Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
georgestephanis/p2026#40 ·
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·