From 980fca9844ebc0e292d40f7d94bdd4a67b383d97 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Fri, 5 Aug 2016 09:32:16 +0800 Subject: [PATCH] remove spread syntax --- frontend/src/components/Header.js | 4 +++- frontend/src/utils/index.js | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 frontend/src/utils/index.js diff --git a/frontend/src/components/Header.js b/frontend/src/components/Header.js index f8f2f485..22f30a44 100644 --- a/frontend/src/components/Header.js +++ b/frontend/src/components/Header.js @@ -1,7 +1,9 @@ import React, { Component, PropTypes } from 'react' +import { objectWithoutProperties } from '../utils' const MapLink = props => { - const { show, linkText, href, linkClass, ...otherProps } = props + const { show, linkText, href, linkClass } = props + const otherProps = objectWithoutProperties(props, ['show', 'linkText', 'href', 'linkClass']) if (!show) { return null } diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js new file mode 100644 index 00000000..1743b9b5 --- /dev/null +++ b/frontend/src/utils/index.js @@ -0,0 +1,9 @@ +export const objectWithoutProperties = (obj, keys) => { + const target = {} + for (let i in obj) { + if (keys.indexOf(i) !== -1) continue + if (!Object.prototype.hasOwnProperty.call(obj, i)) continue + target[i] = obj[i] + } + return target +}