An example in the SurviveJS handbook in the chapter on React and Webpack has me confused.
In Note.jsx
:
import React from 'react';
export default () => <div>Learn Webpack</div>;
This deviates in a number of ways from what appears to be the standard way of declaring React components using JSX:
import React from 'react';
class Note extends React.Component {
render() {
return <div>Learn Webpack</div>;
}
}
How does the first example work?
- How does it know the component is called
Note
so that it can be referred to as<Note/>
in some parent component? Simply by filename match (removing the.jsx
part?) - Where's the
render()
function? And how is it possible to omit it? - What are the limitations of this approach? I am guessing that it only works for wrapping a very simple rendered output, just mapping properties into some HTML...
- Where is this style documented? I can't seem to find any official documentation