Teact: Fix multiple use of callback setter

This commit is contained in:
Alexander Zinchuk 2023-05-15 10:55:50 +02:00
parent 379c5121aa
commit af06317a0f

View File

@ -556,7 +556,7 @@ export function useState<T>(initial?: T, debugKey?: string): [T, StateHookSetter
nextValue: initial,
setter: ((componentInstance) => (newValue: ((current: T) => T) | T) => {
if (typeof newValue === 'function') {
newValue = (newValue as (current: T) => T)(byCursor[cursor].value);
newValue = (newValue as (current: T) => T)(byCursor[cursor].nextValue);
}
if (byCursor[cursor].nextValue === newValue) {