Skip to content

ES6 export bugg. #16750

@Aleksandar-FFWD

Description

@Aleksandar-FFWD

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

yes

Environment

Environment:

  • OS: Windows 10
  • Node: 6.10.2
  • Yarn: 0.24.5
  • npm: 5.0.3
  • Watchman: Not Found
  • Xcode: N/A
  • Android Studio: Version 2.3.0.0 AI-162.4069837

Packages: (wanted => installed)

  • react: 16.0.0-alpha.12 => 16.0.0-alpha.12
  • react-native: 0.48.4 => 0.48.4

Steps to Reproduce

Expected Behavior

Expected behavior would be for console.log(mockNews) to return undefied

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions