跳至正文
Wener Notes

million

约 1 分钟阅读
    • MIT
    • <4kb
    • The Virtual DOM Replacement for React
  • million.dev/blog/virtual-dom
    • Diff the data, not the DOM.
    • 适用场景
      • 大量静态内容但,少部分动态内容
      • "Stable" UI trees - 不做结构性变化
      • 细粒度场景优化
bash
npx million@latest # 自动 init

vite

TypeScript
import million from 'million/compiler';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';

export default defineConfig({
  plugins: [million.vite({ auto: true }), react()],
});

nextjs

TypeScript
import million from 'million/compiler';

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
};

const millionConfig = {
  auto: true, // if you're using RSC: auto: { rsc: true },
};

export default million.next(nextConfig, millionConfig);

Rules

TypeScript
// Block 能被定义为变量

console.log(block(() => <div />)) // ❌ Wrong
export default block(() => <div />) // ❌ Wrong

// 👇👇👇

const Block = block(() => <div />) // ✅ Correct

关联信息

反向链接、本文链接的其他页面和外部资料。

反向链接

  • React Awesome
    笔记 · aidenybai/million

    专门功能选择专业组件 - Headless 配合 UI 组件达到更为理想的结果 · react-table · react-hook-form · floatingui · 选择样式与组件独立的 UI 库 · tailwindcss+daisyui

站内链接

  • react-compiler
    笔记 · react compiler

    参考 · https://playground.react.dev/ · https://react.dev/learn/react-compiler · ESBuild Plugin · https://gist.github.com/sikanhe/f9ac68dd4c78c914c29cc98e7b875466

参考资料

GitHub1 条
其他外链4 条
最近更新commit ff9f085编辑