Hooks not working correctly using off-the-shelf htm@^3.1.0 and preact@^10.5.14
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- javascript
- 領域
- frontend
調査の方向性
まず、htm ^3.1.0 と Preact ^10.5.14 を使って functional-component の mount と unmount を再現し、Preact 10.2.0 と比較します。htm と application package.json の依存関係のバージョン、および記載されている preact/hooks の import を確認します。最新の想定バージョンを使用したときに unmount で __hooks TypeError が発生しなくなれば完了です。
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- JavaScript
- スター
- 9k
- フォーク
- 181
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
developit/htm のほかの issue
-
Sarthak オープン
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
-
Tugas オープン
難易度 5/5 1週間以上 初心者へのやさしさ 10/100
-
Tugas オープン
難易度 5/5 1週間以上 初心者へのやさしさ 1/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 20/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
似ている issue
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
georgestephanis/p2026#40 ·
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·