Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Apply VueUse composables in Vue 3/Nuxt projects to replace custom implementations with battle-tested utilities.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/reactiveOmit.md
1---2category: Reactivity3---45# reactiveOmit67Reactively omit fields from a reactive object.89## Usage1011### Basic Usage1213```ts14import { reactiveOmit } from '@vueuse/core'1516const obj = reactive({17x: 0,18y: 0,19elementX: 0,20elementY: 0,21})2223const picked = reactiveOmit(obj, 'x', 'elementX') // { y: number, elementY: number }24```2526### Predicate Usage2728```ts29import { reactiveOmit } from '@vueuse/core'3031const obj = reactive({32bar: 'bar',33baz: 'should be omit',34foo: 'foo2',35qux: true,36})3738const picked = reactiveOmit(obj, (value, key) => key === 'baz' || value === true)39// { bar: string, foo: string }40```4142### Scenarios4344#### Selectively passing props to child4546```vue47<script setup lang="ts">48import { reactiveOmit } from '@vueuse/core'4950const props = defineProps<{51value: string52color?: string53font?: string54}>()5556const childProps = reactiveOmit(props, 'value')57</script>5859<template>60<div>61<!-- only passes "color" and "font" props to child -->62<ChildComp v-bind="childProps" />63</div>64</template>65```6667## Type Declarations6869```ts70export type ReactiveOmitReturn<71T extends object,72K extends keyof T | undefined = undefined,73> = [K] extends [undefined] ? Partial<T> : Omit<T, Extract<K, keyof T>>74export type ReactiveOmitPredicate<T> = (75value: T[keyof T],76key: keyof T,77) => boolean78export declare function reactiveOmit<T extends object, K extends keyof T>(79obj: T,80...keys: (K | K[])[]81): ReactiveOmitReturn<T, K>82export declare function reactiveOmit<T extends object>(83obj: T,84predicate: ReactiveOmitPredicate<T>,85): ReactiveOmitReturn<T>86```87