Reactive utilities

omit

Edit this page
import { omit } from "solid-js"
function omit<T>(props: T, ...keys: (keyof T)[]): Partial<T>

omit creates a reactive view of a props object with specific keys removed. It provides a way to extract "rest" props without breaking reactivity.

function MyComponent(props) {
const restProps = omit(props, "children")
return (
<>
<div>{props.children}</div>
<Child {...restProps} />
</>
)
}

You can omit multiple keys:

function ParentComponent(props) {
const restProps = omit(props, "name", "age")
return (
<div>
<Greeting name={props.name} />
<PersonalInfo age={props.age} />
<OtherComponent {...restProps} />
</div>
)
}

Migration

// 1.x
import { splitProps } from "solid-js"
const [local, others] = splitProps(props, ["name", "age"])
// use local.name, local.age, and spread others
// 2.0
import { omit } from "solid-js"
const others = omit(props, "name", "age")
// access props.name, props.age directly, and spread others
Report an issue with this page