diff --git a/src/api/reactivity-advanced.md b/src/api/reactivity-advanced.md index a8c5f6350f..70e45a053a 100644 --- a/src/api/reactivity-advanced.md +++ b/src/api/reactivity-advanced.md @@ -72,14 +72,14 @@ Creates a customized ref with explicit control over its dependency tracking and - **Type** ```ts - function customRef(factory: CustomRefFactory): Ref + function customRef(factory: CustomRefFactory): Ref - type CustomRefFactory = ( + type CustomRefFactory = ( track: () => void, trigger: () => void ) => { get: () => T - set: (value: T) => void + set: (value: S) => void } ``` @@ -87,6 +87,8 @@ Creates a customized ref with explicit control over its dependency tracking and `customRef()` expects a factory function, which receives `track` and `trigger` functions as arguments and should return an object with `get` and `set` methods. + The setter can accept a different type from the getter's return type. The setter type defaults to the getter type. + In general, `track()` should be called inside `get()`, and `trigger()` should be called inside `set()`. However, you have full control over when they should be called, or whether they should be called at all. - **Example**