From c2a447b8f9e9c82b2baee0470bb9bec890dd793c Mon Sep 17 00:00:00 2001 From: cqh963852 Date: Sun, 14 Jan 2024 21:17:52 +0800 Subject: [PATCH] fix: add optimization --- examples/todo/src/main.tsx | 12 +++++++----- packages/core/src/createElement.ts | 10 +++++++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/todo/src/main.tsx b/examples/todo/src/main.tsx index 1f59790..f56d587 100644 --- a/examples/todo/src/main.tsx +++ b/examples/todo/src/main.tsx @@ -1,9 +1,9 @@ -import { createState, upsert, useEffect } from "@idealjs/sapling"; +import { createProxy, createRef, upsert, useEffect } from "@idealjs/sapling"; const TodoItem = (props: { name: number; count: number }) => { let { name, count } = props; - const state = createState(0); - const ref = createState(null); + const state = createProxy({ val: 0 }); + const ref = createRef(null); useEffect(() => { const handler = setInterval(() => { state.val++; @@ -25,7 +25,7 @@ const TodoItem = (props: { name: number; count: number }) => {