preact-hooks-debugging
/preact-hooks-debugging
Pomaga naprawić błędy hooków w Preact: nieprawidłowe wywołania, zduplikowane kopie biblioteki, mieszane importy CJS i ESM oraz useId w SSR.
- Autor
- janzsh ↗
- Repozytorium
- portfolio ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 07.11.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 2
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 2
Brak sygnałów. Repozytorium zmienione 07.11.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Pomaga naprawić błędy hooków w Preact: nieprawidłowe wywołania, zduplikowane kopie biblioteki, mieszane importy CJS i ESM oraz useId w SSR.
Oryginalny opis (EN)
Use when Preact hooks fail with invalid hook calls, __H undefined or null errors, mixed CJS/ESM imports, no-build import maps, duplicate Preact copies, useId SSR mismatches, or effect scheduling problems.
Jak działa
- Fast Checks
- Duplicate-Copy Quick Diagnostic
- SSR and Effects
Podgląd SKILL.md
---
name: preact-hooks-debugging
description: "Use when Preact hooks fail with invalid hook calls, __H undefined or null errors, mixed CJS/ESM imports, no-build import maps, duplicate Preact copies, useId SSR mismatches, or effect scheduling problems."
---
# Preact Hooks Debugging
Most hard hook failures are caused by either invalid hook order or two different Preact module instances loaded into the same app.
## Fast Checks
1. Import hooks from `preact/hooks` or `preact/compat`, not a second bundled copy.
2. Confirm all entry points resolve to the same `preact` package instance. Check bundler aliases, linked packages, test-runner aliases, and CDN import maps.
3. For no-build apps, map both `preact` and `preact/` to the same exact version so `preact/hooks` shares core state. See the [preact-no-build-vite-setup](../preact-no-build-vite-setup/SKILL.md) skill.
4. Hooks must run only during function component render and in the same order on every render (no conditional or looped hook calls).
5. If the error mentions `__H`, inspect module duplication *before* changing hook code — the symptom points at installation, not your component.
## Duplicate-Copy Quick Diagnostic
```js
// paste once in a DevTools console for a running app
const mods = performance.getEntriesByType('resource')
.map(e => e.name)
.filter(n => /preact(\.module)?(\?|$|\/hooks)/.test(n));
console.log(mods);
```
Two distinct URLs for `preact` (different versions, or the same version fetched from both `npm` and a CDN) will cause `__H` crashes and context splits.
## SSR and Effects
- `useId()` requires compatible Preact on both server and client, plus a compatible `preact-render-to-string` version. Upgrade together.
- `useEffect()` runs after paint; `useLayoutEffect()` runs during commit. Do not rely on either to create DOM that must exist for the first hydration pass — the server output must already contain it.
- Effect scheduling is influenced by `options.requestAnimationFrame`; any custom scheduler must preserve async post-render semantics.
- In tests, wrap updates with `act()` from `@testing-library/preact` (or your test harness's equivalent) so effects flush before assertions.
Doc anchors: [Hooks](https://preactjs.com/guide/v10/hooks), [Differences to React](https://preactjs.com/guide/v10/differences-to-react).
Pliki w paczce (2)
- SKILL.md 2 KB
- agents/openai.yaml 1 KB
Wersje
W bazie nie ma innych skilli o nazwie preact-hooks-debugging.
Migawka bazy z 13.11.2026 · wersja paczki 94bff228f249 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100preact
Pilnuje, by aplikacja Preact działała jako zamiennik Reacta: sygnały do stanu, warstwa compat i lekkie paczki. - 100preact-hydration-mismatches
Diagnozuje ostrzeżenia hydracji w Preact przy SSR, prerenderingu, Suspense i strumieniowaniu: zduplikowane węzły, zgubiony focus. - 100preact-debug-warnings
Pomaga włączyć preact/debug i odczytać ostrzeżenia: zagnieżdżony HTML, niezgodność hydracji, zduplikowane klucze i ślady stosu. - 95developing-preact
Wspiera tworzenie aplikacji w Preact z natywną architekturą i minimum zależności: składnia HTM, Web Components, parsowanie CSV i JSON, wizualizacje WebGL oraz importy ESM bez buildu. - 100preact
Pomaga budować aplikacje w Preact, 3-kilobajtowej alternatywie dla Reacta z tym samym API, hookami, JSX i sygnałami @preact/signals, także z biblioteką komponentów React przez preact/compat. - 100preact-buildless-frontend
Buduje frontendy ESM działające bezpośrednio w przeglądarce bez bundlerów: import maps, importy z CDN, cache-busting, routing hashowy i wzorce wydajności.