/**
 * 优先级调度的展示，高优先级的任务（点击事件产生的更新）会打断低
 * 优先级的任务（直接指向setState的更新）
 */ import React , { useState , useEffect } from '../packages/react' ; export const PriorityScheduling = ( ) => { const [ count , updateCount ] = useState ( 0 ) ; const onClick = ( ) => { updateCount ( ( count ) => count + 2 ) ; } ; console . log ( { count } ) ; useEffect ( ( ) => { const button = document . getElementById ( 'discretEventDispatcher' ) ! ; setTimeout ( ( ) => updateCount ( 1 ) , 1000 ) ; setTimeout ( ( ) => { button . click ( ) ; } , 1030 ) ; } , [ ] ) ; return ( < div > < button id = "discretEventDispatcher" onClick = { onClick } > 增加2 < /button> < div > { Array . from ( new Array ( 10000 ) ) . map ( ( v , index ) => ( < span key = { index } > { count } < /span>))} < /div> < /div>); } ;