Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Explicitly setting the dynamically imported component
- Loading branch information
Showing
3 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3cf5222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! Thanks for your great job!
What is mean left part of:
const { default: component } = await importComponent();
if later it used as
?
3cf5222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valorloff The dynamic import returns an object with what was imported and the
default
property is what we want. So we are storing that in a variable calledcomponent
and storing it in our state.3cf5222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jayair
thanks!
and where i can read about dynamic import default return?
3cf5222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valorloff To be honest I haven't found some really good documentation for it. Partly because it's still a proposal. Here is some more info on it - http://2ality.com/2017/01/import-operator.html#loading-code-on-demand
3cf5222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is quite suitable explanation, thanks)