It is that situation, when you get some code, which works, but you don't know how. What does this declaration method do?
const { actions: { createRole, updateRole } = {} } = props;
It is that situation, when you get some code, which works, but you don't know how. What does this declaration method do?
const { actions: { createRole, updateRole } = {} } = props;
The code uses destructing for an nested object. The following example might help for understanding this new JavaScript syntax (has been introduced with ES6):
const user = {
id: 339,
name: 'Fred',
age: 42,
education: {
degree: 'Masters'
}
};
const {education: {degree}} = user;
console.log(degree); //prints: Masters
I would recommend the following resource for further examples: https://medium.com/@pyrolistical/destructuring-nested-objects-9dabdd01a3b8