What is the difference between:
import App from '../components/App';
and
var App = require('../components/App');
both are used to get components but it is not solving my query asked here: Uncaught Error: Minified React error #130
What is the difference between:
import App from '../components/App';
and
var App = require('../components/App');
both are used to get components but it is not solving my query asked here: Uncaught Error: Minified React error #130
import/export is one of the ES6 feauture which is used to import/export modules/components. Eg: You can do a named/default export of the React Component. Similarly, you can import them.
export default App
Though most of the web browsers won't understand ES6, Babel or any of the other tool is used for transpilation. Under the hood, these statements are converted to require() by default which uses common.js in node environment.
import/export is one of the ES6 features, you won't see the advantage by just importing the default export. for example you can export other components...etc like this
export default MainComponent;
export {OtherComponent}
and you can import them using ES6:
import MainComponent, {OtherComponent} from '../components/App';
you can do this use ES5 for sure but this is faster...