🎈 perf(购物页面): 优化购物页面的删除功能

This commit is contained in:
xuan
2022-10-28 16:28:58 +08:00
parent 41dd477f2e
commit c0d3f61806
4 changed files with 36 additions and 11 deletions
+1 -1
View File
@@ -167,7 +167,7 @@ export function usePropsValue<T>(options: UsePropsValueOptions<T>) {
}
const setState = useCallback((v: SetStateAction<T>, forceTrigger: boolean = false) => {
// `forceTrigger` means trigger `onChange` even if `v` is the same as `stateRef.current`
// `forceTrigger` 意思是 触发 `onChange` 不管 `v` 是否和 `stateRef.current` 相等
const nextValue = typeof v === 'function' ? (v as (prevState: T) => T)(stateRef.current) : v
if (!forceTrigger && nextValue === stateRef.current) return
stateRef.current = nextValue