Reputation: 8284
In javascript, to destruct multiple props, how do I set prop1, prop2, prop3 with default value individually?
const {
prop1,
prop2,
prop3
} = obj.props;
Upvotes: 1
Views: 447
Reputation: 4578
The same way you would set default values in function params, with an =
sign.
const {
prop1 = 'default value',
prop2,
prop3,
} = obj.props;
Upvotes: 2