Reactive Utilities

mergeProps

Edit this page
import { mergeProps } from "solid-js"
function mergeProps(...sources: any): any

A reactive object merge method. Useful for setting default props for components in case caller doesn't provide them. Or cloning the props object including reactive properties.

This method works by using a proxy and resolving properties in reverse order. This allows for dynamic tracking of properties that aren't present when the prop object is first merged.

// default props
props = mergeProps({ name: "Smith" }, props)
// clone props
newProps = mergeProps(props)
// merge props
props = mergeProps(props, otherProps)
Report an issue with this page