When working with components, sometimes we need to send one specific property just when matches specific condition as an example:
function MyComponent = () => {
return (
<Select
label="Countries"
options={}
required
/>
);
}
if we want to send required just when matches specific conditions, we can spread the properties
function MyComponent = () => {
return (
<Select
label="Countries"
options={}
{...(shouldBeRequired && { required })}
/>
);
}
Top comments (0)