Skip to content

Instantly share code, notes, and snippets.

@at0g
Created May 8, 2015 07:47
Show Gist options
  • Select an option

  • Save at0g/ccca9e7b3923c9da66ee to your computer and use it in GitHub Desktop.

Select an option

Save at0g/ccca9e7b3923c9da66ee to your computer and use it in GitHub Desktop.
react with spread vs without spread
'use strict';
var React = require('react');
var Component = React.createComponent({
getDefaultProps: function () {
return {
Component: 'div',
foo: 'foo',
bar: 'bar',
baz: 'baz'
}
},
render: function () {
var { Component, ...rest } = this.props;
return <Component {..rest} />;
}
});
module.exports = Component;
'use strict';
var React = require('react');
var Component = React.createComponent({
getDefaultProps: function () {
return {
Component: 'div',
foo: 'foo',
bar: 'bar',
baz: 'baz'
}
},
render: function () {
var Component = this.props.Component;
return <Component foo={this.props.foo} bar={this.props.bar} baz={this.props.baz} />;
}
});
module.exports = Component;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment