0👍
✅
Looks like your issue is that you’re storing MyApp under window, but then trying to access it directly. You’ve also got a capital M in the definition, and a lowercase when your accessing it.
Here’s a working example:
window.MyApp = {
app: null,
icons: {
SearchIcon : 'Hello!'
},
};
const { SearchIcon } = window.MyApp.icons;
console.log(SearchIcon);
For more info, see the docs on object destructuring.
Hope that helps 🙂
Source:stackexchange.com