Skip to content

Instantly share code, notes, and snippets.

@miguelrk
miguelrk / fetch-form.tsx
Last active April 10, 2024 07:04
An isomorphic form component that overrides the default submit (GET/POST) with an HTTP Request using fetch to allow for GET/POST/PUT/PATCH/DELETE
// adapted from https://stackoverflow.com/a/74202858
import type { ComponentChildren, JSX } from "preact";
export type FormFetchProps = JSX.IntrinsicElements["form"] & {
id: string;
method: "get" | "post" | "put" | "patch" | "delete";
action: string;
children?: ComponentChildren;
};
@marvinhagemeister
marvinhagemeister / bind-plugin.ts
Last active January 9, 2024 20:31
Preact Signals `bind:value`
import { options } from "preact";
import { Signal } from "@preact/signals";
// Add `bind:value` to JSX types
declare global {
namespace preact.createElement.JSX {
interface HTMLAttributes {
"bind:value"?: Signal<string | string[] | number | undefined>;
}
}