Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

assign multiple attributes by destructuring props react

// you can assign multiple attributes by destructuring props in react without
// doing the common way: x={props.v} one by one till your keyboard break.
// example:
<input {...props} />

// you may want to filter the props before blindly destructure it inside the
// element.
// example:
const {onClick, onChange, ...filtered} = props
<input {...filtered} />
 
PREVIOUS NEXT
Tagged: #assign #multiple #attributes #destructuring #props #react
ADD COMMENT
Topic
Name
2+5 =