omit
Edit this pageSolid 2.0 —
splitProps has been replaced by omit in Solid 2.0. Instead of splitting props into multiple groups, omit creates a reactive view of the props without the listed keys.
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.ximport { splitProps } from "solid-js"const [local, others] = splitProps(props, ["name", "age"])// use local.name, local.age, and spread others
// 2.0import { omit } from "solid-js"const others = omit(props, "name", "age")// access props.name, props.age directly, and spread others