Created
May 8, 2015 07:47
-
-
Save at0g/ccca9e7b3923c9da66ee to your computer and use it in GitHub Desktop.
react with spread vs without spread
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| '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