[Docs] Fix example in doc comment (#2804)

This commit is contained in:
bymyself
2025-03-02 12:22:55 -07:00
committed by GitHub
parent 790b284a23
commit 3493a827ee

View File

@@ -3,11 +3,12 @@
* Does not observe deep changes.
*
* @example
* const { get, set } = useValueTransform<ResultItem[], string[]>(
* items => items.map(formatPath)
* )
*
* const transformFunction = (items: string[]) => items.map(item => `root/${item}.ext`)
* const { get, set } = useValueTransform(transformFunction, [])
* Object.defineProperty(obj, 'value', { get, set })
*
* obj.value = ['filename1', 'filename2']
* console.log(obj.value) // ["root/filename1.ext", "root/filename2.ext"]
*/
export function useValueTransform<Internal, External>(
transform: (value: Internal) => External,