/preact_utils

Preact typings and useful hooks that can be used with Deno.

Primary LanguageJavaScriptMIT LicenseMIT

Preact Utils for Deno

preact_utils is a Deno port of Preact and a small library of custom hooks.

License Repository ci codecov

History

I repeatedly failed to get Preact typings to work with Deno in VSCode. There is some discussion here and even a link to a repository with a supposed fix, but I couldn't get it to work. Until version v1.0.0-alpha I imported the bundled sources from a CDN and only included the typings.

Recently, I discovered a problem which prevented me from importing the library from multiple locations. Porting the whole library seemed to do the trick, even though I am unsure of the exact reason. Since porting currently happens manually, the version of preact provided here might be outdated.

Usage

The mod.ts module exports all of Preact, native hooks, as well as the custom hooks under hooks:

// Replace 'master' with the desired version.
import * as React from "https://raw.githubusercontent.com/eibens/preact_utils/master/mod.ts";

The preact.ts module exports all core Preact features with Deno compatible typings. The hooks.ts module exports all Preact hooks:

import * as React from "./preact.ts";
import { useEffect } from "./hooks.ts";

The hooks directory contains custom hooks that I find useful. The hooks/mod.ts module exports all custom hooks:

import { useHover } from "./hooks/mod.ts";

License

See the LICENSE file. Everything under preact was copied from the original preact project and preact/LICENSE.