mergeProps
Edit this pagemergeProps merges prop sources from left to right and resolves reads from the last source that defines each property.
Import
import { mergeProps } from "solid-js";Type
function mergeProps<T extends unknown[]>(...sources: T): MergeProps<T>;Parameters
sources
- Type:
unknown[]
Prop sources to merge.
Return value
- Type:
MergeProps<T>
Returns a merged object with lazy reactive property resolution across the provided sources.
Behavior
mergePropsis shallow.- The last source with a non-
undefinedvalue for a property wins. - Function sources are wrapped so property reads stay reactive.
- When reactive proxies are involved, the merged result uses proxy-backed property resolution.
- Property lookups are resolved when read rather than copied eagerly from every source.
Examples
Basic usage
import { mergeProps } from "solid-js";
function Greeting(props) { const merged = mergeProps({ greeting: "Hello", name: "Smith" }, props);
return ( <div> {merged.greeting} {merged.name} </div> );}