Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Hooks not working correctly using off-the-shelf htm@^3.1.0 and preact@^10.5.14

オープン
#209 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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 はありません

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

developit/htm のほかの issue

developit/htm の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。