From a378f00f0e4909cb81c177af181c401c6cd2b79c Mon Sep 17 00:00:00 2001 From: Alexey Kucherenko Date: Wed, 2 Nov 2016 17:19:58 +0300 Subject: [PATCH] bump to react-router 3.0.0 and fix issue with passing unknown props --- package.json | 4 ++-- src/index.js | 20 ++++++++++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8983305..0102748 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "dependencies": {}, "peerDependencies": { "react": ">=0.14.0", - "react-router": "^2.4.0" + "react-router": "^3.0.0" }, "devDependencies": { "eslint-config-jonnybuchanan": "3.2.1", @@ -27,7 +27,7 @@ "react": "15.2.1", "react-addons-test-utils": "15.2.1", "react-dom": "15.2.1", - "react-router": "2.5.2", + "react-router": "3.0.0", "bootstrap": "3.3.6" }, diff --git a/src/index.js b/src/index.js index c46bbd9..e053312 100644 --- a/src/index.js +++ b/src/index.js @@ -13,6 +13,20 @@ function createLocationDescriptor({to, query, hash, state}) { return {query, hash, state, ...to} } +function omitProps(props, omittedPropNames) { + const isOmittedProp = {} + omittedPropNames.forEach(propName => { isOmittedProp[propName] = true }) + + const elementProps = {} + Object.entries(props).forEach(([propName, propValue]) => { + if (!isOmittedProp[propName]) { + elementProps[propName] = propValue + } + }) + + return elementProps +} + module.exports = function activeComponent(Component, options) { if (!Component) { throw new Error('activeComponent() must be given a tag name or React component') @@ -73,10 +87,12 @@ module.exports = function activeComponent(Component, options) { } } + let componentProps = omitProps(props, ['params', 'location', 'routes']) + if (!link) { - return {this.props.children} + return {this.props.children} } - return + return {this.props.children}