Skip to content

Commit

Permalink
Removed Object.assign in favor o rest spread.
Browse files Browse the repository at this point in the history
  • Loading branch information
alansouzati committed Feb 12, 2016
1 parent 73b1d87 commit e51be26
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .babelrc
@@ -1,4 +1,4 @@
{
"presets": [ "es2015", "react" ],
"plugins": [ "add-module-exports", "transform-object-assign" ]
"plugins": [ "add-module-exports", "transform-object-rest-spread" ]
}
4 changes: 2 additions & 2 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "jsx-to-string",
"version": "0.2.9",
"version": "0.2.10",
"description": "Parse your React JSX component to string",
"main": "lib/index.js",
"scripts": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"babel-cli": "^6.1.18",
"babel-core": "^6.1.18",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-transform-object-assign": "^6.3.13",
"babel-plugin-transform-object-rest-spread": "^6.3.13",
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"tape": "^4.0.0"
Expand Down
10 changes: 6 additions & 4 deletions src/index.js
Expand Up @@ -10,19 +10,21 @@ function isDefaultProp(defaultProps, key, value) {

function jsxToString(component, options) {

let opts = Object.assign({
const baseOpts = {
displayName: component.type.displayName || component.type.name || component.type,
ignoreProps: [],
keyValueOverride: {},
spacing: 0,
}, options);
spacing: 0
};

let opts = {...baseOpts, ...options};

let componentData = {
name: opts.displayName
};

delete opts.displayName;

if (component.props) {
componentData.props = Object.keys(component.props).map(
(key) => {
Expand Down

0 comments on commit e51be26

Please sign in to comment.