ffxsam / ffx-meteor-react-boilerplate

Meteor 1.4 + React boilerplate (DEPRECATED/ABANDONED) 👋
133 stars 20 forks source link

New React component syntax #6

Closed andersr closed 8 years ago

andersr commented 8 years ago

Hi - I'm really finding this boilerplate repo to be a great learning tool. All your detailed comments are super helpful! One detail, however, has me completely stumped.

Previously, when creating a React component, I would do something like this:

MyComponent = React.createClass({
  render(){
    return <div>
      Component content
     </div>
  }
});

However, in your repo, you are creating a component as follows:

import React from 'react';

export default MyComponent = (props) => {
  <div>
      Component content
   </div>
}

How is this being defined as a React component? It seems as if all that is happening here is that a generic MyComponent variable or module is being defined. I would expect either Foo = React.createClass or class Foo extends React.Component

I've tried googling around, but all the examples I've found use either the create or extend syntax.

If you could update your comments or provide an explanation (or just link to a good explanation), it would be most appreciated!

Thanks so much!

andersr commented 8 years ago

Oh, now I see, this is an example of a stateless React component, as you do explain in your comments. All clear now, pls ignore :}

ffxsam commented 8 years ago

@andersr You got it! I tried to cover everything possible :)

BTW, for anyone else stumbling on this issue, the link to the explanation is here:

https://github.com/ffxsam/ffx-meteor-react-boilerplate/blob/example/client/layouts/MainLayout.jsx