Skip to content

Instantly share code, notes, and snippets.

@selvagsz
Last active July 12, 2016 15:27
Show Gist options
  • Save selvagsz/148ed2303aa6958948c5c211519b96ed to your computer and use it in GitHub Desktop.
Save selvagsz/148ed2303aa6958948c5c211519b96ed to your computer and use it in GitHub Desktop.
  • If you have some unwanted properties in your props, do not drop all of them using {...props} to the child component. Pass the props that are needed by the component. (facebook/react#7157 (comment))
// BAD (if there are unwanted props)
render() {
  return (
    <Foo {...this.props} />
  );
}

// GOOD
render() {
  var { unwantedProps, ...neededProps } = this.props;
  return (
    <Foo {...neededProps} />
  );
}
var PurpleComponent = React.createClass({
  render: function() {
    return <FirstComponent {...this.props} color="purple" />;
  },
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment