Codesandbox-client: Export & Import for React applications

Created on 25 Mar 2018  路  3Comments  路  Source: codesandbox/codesandbox-client

I have a question:

Is this case right? or I missing something?

When I use this code in code sandbox its work:

// File Photo.js
export default Photo;

// File index.js
export Photo from "./Photo/Photo";
export Comments from "./Comments/Comments";

But when I install the project using GitHub on my local machine its not working until I change the code to this:

// File Photo.js is the same
// File index.js
import Photo from "./Photo/Photo";
import Comments from "./Comments/Comments";

export default {
    Photo,
    Comments
};

The error is shown on my local machine './../components' does not contain an export named 'Photo'

Most helpful comment

Closing this one since it's solved! Thanks @Komar0ff 馃槃

All 3 comments

Hello @YazanAabeed

You can't use the "default export" for the two components in this way.
In this situation, it is correct to use "named export".

You can check this example, it works both in the sandbox and on the local machine

Hello @Komar0ff
Thank you for your help and your time 馃槃 馃敟

Closing this one since it's solved! Thanks @Komar0ff 馃槃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Haroenv picture Haroenv  路  3Comments

zocky picture zocky  路  3Comments

NataliaTepluhina picture NataliaTepluhina  路  3Comments

oliversturm picture oliversturm  路  3Comments

oskarabc picture oskarabc  路  3Comments