-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ES6 export bugg. #16750
Comments
Hey @Aleksandar-FFWD, want to clarify how " You can read about it online more, but essentially by using " import mockNews from '<direct filepath to that default export file>';
console.log(mockNews); You need to first |
Assuming this issue can be closed at this point. |
@dawsbot is right, this is just how JS works. The name of default exports is |
Hey, @dawsbot. Problem is when I'm exporting the file with is that expected behavior or not? |
Is this a bug report?
Yes
Have you read the Contributing Guidelines?
yes
Environment
Environment:
Packages: (wanted => installed)
Steps to Reproduce
Expected Behavior
Expected behavior would be for
console.log(mockNews)
to returnundefied
Actual Behavior
So I was playing around with mock data for the app when I noticed unexpected behavior while exporting .js files
If you export the file like so:
export default mockNews = [{ ID: 0, Title: Lorem Ipsum' }];
When you run
console.log(mockNews )
it is available in every single file in the project even if it is not imported.However if you export a variable like:
var mockNews = [{ ID: 0, Title: Lorem Ipsum' }];
export default mockNews;
Now the behavior is normal. You only have the
mockNews
if you import the file.Seams to me that it is not an expected behavior or I'm missing something.
Reproducible Demo
The text was updated successfully, but these errors were encountered: