If you are using this already, consider changes soon due the discussion around current ESX proposal.
Feel free to keep an eye on udomsay as that will be the implementation reference for consumers.
// HOW TO INSTRUCTIONS | |
// 1. Open Claude Desktop | |
// 2. Go to Help -> Enable Developer Mode | |
// 3. Navigate Developer Tools window named "Developer Tools - https://claude.ai" | |
// 4. Go to "Console" tab | |
// 5. Type "allow pasting" and hit Enter | |
// 6. Paste this snippet and hit Enter | |
// From now on, all MCP calls will be auto-approved |
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>; | |
} | |
} |
import { useSignal, signal, effect } from '@preact/signals'; | |
import { useLayoutEffect, useMemo, useRef } from 'preact/hooks'; | |
/** @template T @typedef {T extends (infer U)[] ? U : never} Items */ | |
/** @param {{ v, k?, f }} props */ | |
const Item = ({ v, k, f }) => f(v, k); | |
/** | |
* Like signal.value.map(fn), but doesn't re-render. |
*.wasm |
If you are using this already, consider changes soon due the discussion around current ESX proposal.
Feel free to keep an eye on udomsay as that will be the implementation reference for consumers.
import { hook, OptionsTypes } from './preact-options-helper.ts';
hook(OptionsTypes.RENDER, (old, vnode) => {
let component = vnode.__c;
if (component) {
// do stuff with the component instance
} else {
console.log(vnode.props);
}
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>bare-bones exhaust() vs ternary #jsbench #jsperf #jsbench #jsperf</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"/> | |
<title>exhaust() vs ternary #jsbench #jsperf</title> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
<script src="./suite.js"></script> | |
</head> | |
<body> | |
<h1>Open the console to view the results</h1> |
This is a standalone Preact 10+ implementation of the deprecated replaceNode
parameter from Preact 10.
It provides a way to render or hydrate a Preact tree using a subset of the children within the parent element passed to render():
<body>
<div id="root"> ⬅ we pass this to render() as the parent DOM element...
/* | |
* With [email protected], Effect-A is triggered, then Effect-B is triggered. (expected) | |
* With [email protected], Effect-B is triggered, then Effect-A is triggered. | |
* | |
* `useLayoutEffect` is more appropriate for Effect-A, maybe. | |
* | |
* BTW, behaviours will be same if removing React.memo call (line.39) | |
*/ | |
const EditorWrapper_: React.VFC<{ |