Skip to content

Commit 2c91ad8

Browse files
broBinChenbinge_c-admin
andauthored
perf(computedWithControl): Optimize with shallowRef (#4826)
Co-authored-by: binge_c-admin <totchinaa@gmail.com>
1 parent f6f0bc1 commit 2c91ad8

File tree

1 file changed

+5
-5
lines changed
  • packages/shared/computedWithControl

1 file changed

+5
-5
lines changed

packages/shared/computedWithControl/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { ComputedGetter, ComputedRef, WatchSource, WritableComputedOptions, WritableComputedRef } from 'vue'
22
import type { Fn } from '../utils'
3-
import { customRef, shallowRef, watch } from 'vue'
3+
import { customRef, watch } from 'vue'
44

55
export interface ComputedWithControlRefExtra {
66
/**
@@ -37,10 +37,10 @@ export function computedWithControl<T, S>(
3737
let v: T = undefined!
3838
let track: Fn
3939
let trigger: Fn
40-
const dirty = shallowRef(true)
40+
let dirty = true
4141

4242
const update = () => {
43-
dirty.value = true
43+
dirty = true
4444
trigger()
4545
}
4646

@@ -55,9 +55,9 @@ export function computedWithControl<T, S>(
5555

5656
return {
5757
get() {
58-
if (dirty.value) {
58+
if (dirty) {
5959
v = get(v)
60-
dirty.value = false
60+
dirty = false
6161
}
6262
track()
6363
return v

0 commit comments

Comments
 (0)