1- import { useState , memo , h , render , useEffect } from "../../src/index"
21
3- // 注入样式(包含CSS动画)
2+ import { useState , memo , render , useEffect , h } from "fre"
3+ // import { useState, memo, render, useEffect } from "preact/compat"
4+ // import {h} from 'preact' // Using Preact, you can see how the main thread gets blocked.
5+
46const styleSheet = document . createElement ( "style" )
57styleSheet . textContent = `
68.container {
@@ -58,11 +60,11 @@ const SlowDot = memo(({ x, y, size, text }) => {
5860 )
5961} )
6062
61- // Sierpinski 三角形组件
6263const targetSize = 25
6364
6465const getValue = ( key , kid ) => {
65- const number = kid . props . nodeValue
66+ console . log ( kid )
67+ const number = kid ?. props ?. nodeValue || kid
6668 return number
6769}
6870
@@ -97,11 +99,9 @@ const SierpinskiTriangle = memo(({ x, y, s, children }) => {
9799 )
98100} )
99101
100- // 主应用组件
101102const App = ( ) => {
102103 const [ seconds , setSeconds ] = useState ( 0 )
103104
104- // 仅更新秒数
105105 useEffect ( ( ) => {
106106 const timer = setInterval ( ( ) => {
107107 setSeconds ( prev => ( prev % 10 ) + 1 )
@@ -122,5 +122,4 @@ const App = () => {
122122 )
123123}
124124
125- // 渲染入口
126125render ( < App /> , document . body )
0 commit comments