onefinestay / react-daterange-picker

Other
563 stars 208 forks source link

Use React 0.14's stateless components #95

Closed rolyatmax closed 8 years ago

rolyatmax commented 8 years ago

Some spots where we could use React 0.14's stateless components.

depends on #79

rolyatmax commented 8 years ago

@AlanFoster Let me know what you think of this.

AlanFoster commented 8 years ago

I'm a fan of the newer notation; But we should be consistent with the rest of the code base. Particularly since this will make it harder for us to add propType and defaultPropType information in the future if we need to. Likewise newcomers to React may not fully appreciate the terseness of this PR change.

I'll close this PR for now, but we might re-visit it in the future!

rolyatmax commented 8 years ago

Do you mean that to use React's stateless functions syntax, we would need to use only stateless components in order to be consistent?

Or do you mean we should be consistent with how we define stateless components?:

const Link = ({href, text}) => <a href={href}>{text}</a>;

// versus

function Link({href, text}) {
    return <a href={href}>{text}</a>;
}

Also, for what it's worth, you can add propType validation like so:

function MyComponent({children}) {
    return <div>{children}</div>;
}

MyComponent.propTypes = {
    children: React.PropTypes.node.isRequired
};