Hooks not working correctly using off-the-shelf htm@^3.1.0 and preact@^10.5.14
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- frontend
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện việc mount và unmount functional-component với htm ^3.1.0 và Preact ^10.5.14, rồi so sánh với Preact 10.2.0. Kiểm tra các phiên bản dependency trong htm và application package.json cũng như các import preact/hooks được liệt kê; hoàn tất khi unmount không còn gây ra __hooks TypeError trong khi sử dụng các phiên bản mới nhất được dự định.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- JavaScript
- Star
- 9k
- Fork
- 181
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của developit/htm
-
Sarthak Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
-
Tugas Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 10/100
-
Tugas Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
-
type checking templates Đang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 35/100
Tất cả issue của developit/htm
Issue tương tự
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Improve Title Support Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
georgestephanis/p2026#40 ·
-
Enatega Customer and Rider app: Add-ons price is not visible to customer after order is placed. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Margaret-Petersen/food-delivery-app-clone-react-native#1981 ·