freddyrangel/playing-with-react-and-d3

Unfinished tutorial explanation: Chart not defined...

Closed this issue · 1 comments

But why does it still work?

//unfinished/src/index.jsx
import './main.css';
import React from 'react';
import ReactDOM from 'react-dom';
import Charts from './components/chart.jsx';

const mountingPoint = document.createElement('div');
mountingPoint.className = 'react-app';
document.body.appendChild(mountingPoint);
ReactDOM.render(<Charts/>, mountingPoint);

// unfinished/src/components/chart.jsx

import React from 'react';

export default (props) => {
    return <h1>Unfinished: Hello, World!</h1>;
}

But somehow it is still rendering when Charts was not defined? Charts get mapped to the only (props) there?

You don't need to name a default export. When you import that module, you can call it anything you want. However, if you didn't use export default, that wouldn't work.