Open collinglass opened 8 years ago
I think you mean React elements? Thats what those functions are. They are stateless and immutable virtual DOM representation. See: http://stackoverflow.com/questions/30971395/difference-between-react-component-and-react-element
No. From the article I linked:
"React 0.14 introduced a new syntax for defining components, as functions of props:
const MyComponent = props => (
<div className={props.className}/>
);
This is by far my favourite method for defining React components..."
And then I see people adding propTypes like so:
MyComponent.propTypes = {
className: PropTypes.string
}
+1 I'm heavily in favor of this being the standard for presentational components.
How would one use the connect and connectData decorators?
I think this would make it clear that you have to connect your data in smart components and pass everything as props to your dumb components. By looking at the code you can instantly see if a component is meant to be a dumb component or a smart one. I'd say keep the ES2015 style for smart components and use stateless functional components for dumb ones.
I recently read this article by Cam Jackson. It describes using functions for react components.
Is there any desire to move to this approach? How would one use the connect and connectData decorators?