Why does my React Component Export not work? Why does my React Component Export not work? reactjs reactjs

Why does my React Component Export not work?


Because your export is default you don't need braces around your import component name:

import Hello from './hello';

Here's a verbose technical article from Axel Rauschmayer on the final ES6 modules syntax that you might find useful.

And here's a slightly less techy post about the same topic.


when you import the default class you use

import ClassName from 'something';

and when you import other classes you use

import {ClassName} from 'something';

an example:

in hello.js file

import React from 'react';class Hello extends React.Component{   render(){       return (           <h1>Hello, world!</h1>       )    }}class Other extends React.Component{   render(){       return (           <h1>Hello, world!</h1>       )    }}export default Hello;export Other;

in other file

import Hello, {Other} from './hello';

tip: you could also import the default class with other name

import Component, {Other} from './hello';