Skip to content

virtualstate/memo

Repository files navigation

@virtualstate/memo

memo for JSX values.

Support

Node.js supported Deno supported Bun supported

Test Coverage

100%25 lines covered 100%25 statements covered 100%25 functions covered 100%25 branches covered

Usage

import { memo } from "@virtualstate/memo";
import { descendants } from "@virtualstate/focus";
import { Component, Body } from "./somewhere";

const tree = memo(
    <>
        <Component />
        <main>
            <Body />
        </main>
    </>
);

// On the first usage, the tree will be memo'd as it is read
console.log(await descendants(tree));

// Uses the memo'd version, Component & Body aren't called again
console.log(await descendants(tree));