You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
let index =0
let stateArr =[]
function useState(initvalue){
stateArr[i] = stateArr[i] || initvalue
let cunrrent = index //保存对应的下标 执行setState直接更新对应的
function setState(newValue){
stateArr[current] = newValue
render();
}
return [stateArr[index++],setState]
}
render(){
index=0 // render的时候清空 从头开始
}
The text was updated successfully, but these errors were encountered:
useState
如果定义多个useState呢?
The text was updated successfully, but these errors were encountered: