Accepted answer

try defaulting the exports in your components:

import react from 'react';
import navbar from 'react-bootstrap/lib/navbar';

export default class mynavbar extends react.component {
      return (
        <navbar classname="navbar-dark" fluid>

by using default you express that's going to be member in that module which would be imported if no specific member name is provided. you could also express you want to import the specific member called mynavbar by doing so: import {mynavbar} from './comp/my-navbar.jsx'; in this case, no default is needed


there are two different ways of importing components in react and the recommended way is component way

  1. library way(not recommended)
  2. component way(recommended)

pfb detail explanation

library way of importing

import { button } from 'react-bootstrap';
import { flatbutton } from 'material-ui';

this is nice and handy but it does not only bundles button and flatbutton (and their dependencies) but the whole libraries.

component way of importing

one way to alleviate it is to try to only import or require what is needed, lets say the component way. using the same example:

import button from 'react-bootstrap/lib/button';
import flatbutton from 'material-ui/lib/flat-button';

this will only bundle button, flatbutton and their respective dependencies. but not the whole library. so i would try to get rid of all your library imports and use the component way instead.

if you are not using lot of components then it should reduce considerably the size of your bundled file.


i hope this is helpfull

step 1: app.js is (main module) import the login module

import react, { component } from 'react';
import './app.css';
import login from './login/login';

class app extends component {
  render() {
    return (
      <login />

export default app;

step 2: create login folder and create login.js file and customize your needs it automatically render to app.js example login.js

import react, { component } from 'react';
import '../login/login.css';

class login extends component {
  render() {
    return (
      <div classname="app">
        <header classname="app-header">
          <h1 classname="app-title">welcome to react</h1>
        <p classname="app-intro">
          to get started, edit <code>src/app.js</code> and save to reload.

export default login;


mdn has really nice documentation for all the new ways to import and export modules is es 6 import-mdn . a brief description of it in regards to your question you could've either:

  1. declared the component you were exporting as the 'default' component that this module was exporting: export default class mynavbar extends react.component { , and so when importing your 'mynavbar' you don't have to put curly braces around it : import mynavbar from './comp/my-navbar.jsx';. not putting curly braces around an import though is telling the document that this component was declared as an 'export default'. if it wasn't you'll get an error (as you did).

  2. if you didn't want to declare your 'mynavbar' as a default export when exporting it : export class mynavbar extends react.component { , then you would have to wrap your import of 'mynavbar in curly braces: import {mynavbar} from './comp/my-navbar.jsx';

i think that since you only had one component in your './comp/my-navbar.jsx' file it's cool to make it the default export. if you'd had more components like mynavbar1, mynavbar2, mynavbar3 then i wouldn't make either or them a default and to import selected components of a module when the module hasn't declared any one thing a default you can use: import {foo, bar} from "my-module"; where foo and bar are multiple members of your module.

definitely read the mdn doc it has good examples for the syntax. hopefully this helps with a little more of an explanation for anyone that's looking to toy with es 6 and component import/exports in react.


to export a single component in es6, you can use export default as follows:

class myclass extends component {

export default myclass;

and now you use the following syntax to import that module:

import myclass from './myclass.react'

if you are looking to export multiple components from a single file the declaration would look something like this:

export class myclass1 extends component {

export class myclass2 extends component {

and now you can use the following syntax to import those files:

import {myclass1, myclass2} from './myclass.react'


wrapping components with braces if no default exports:

import {mynavbar} from './comp/my-navbar.jsx';

or import multiple components from single module file

import {mynavbar1, mynavbar2} from './module';

Related Query

More Query from same tag