From 92f5188844010ab873e9ed1270e1dca7e9276e33 Mon Sep 17 00:00:00 2001 From: Ankur Taxali Date: Thu, 21 Dec 2017 11:43:53 +0530 Subject: [PATCH 1/3] Use the prop-types library instead. In 15.5, instead of accessing PropTypes from the main React object, install the prop-types package and import them from there See: "https://reactjs.org/blog/2017/04/07/react-v15.5.0.html#migrating-from-reactproptypes" --- package.json | 3 ++- src/pacomo.js | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index e7aa5aa..07e84a4 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,8 @@ }, "dependencies": { "babel-polyfill": "^6.1.18", - "classnames": "^2.1.3" + "classnames": "^2.1.3", + "prop-types": "^15.6.0" }, "devDependencies": { "babel-cli": "^6.1.18", diff --git a/src/pacomo.js b/src/pacomo.js index 75f886d..d5385d6 100644 --- a/src/pacomo.js +++ b/src/pacomo.js @@ -1,5 +1,6 @@ import classNames from 'classnames' -import { isValidElement, cloneElement, Children, PropTypes } from 'react' +import PropTypes from 'prop-types' +import { isValidElement, cloneElement, Children } from 'react' export function prefixedClassNames(prefix, ...args) { @@ -46,7 +47,7 @@ function transformElementProps(props, fn, childrenOnly) { changes.children = transformedChildren } } - + if (!childrenOnly) { for (let key of Object.keys(props)) { if (key == 'children') continue @@ -150,7 +151,7 @@ export function withPackageName(packageName) { // Add `className` propType, if none exists DecoratedComponent.propTypes = { className: PropTypes.string, ...componentClass.propTypes } - return DecoratedComponent + return DecoratedComponent }, } } From 44f8f815ecb367af579b7c2ec7da7e4e0f42cf6c Mon Sep 17 00:00:00 2001 From: Ankur Taxali Date: Thu, 21 Dec 2017 12:11:26 +0530 Subject: [PATCH 2/3] [Tests] Use the prop-types library instead --- test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test.js b/test.js index 9b9243e..e258891 100644 --- a/test.js +++ b/test.js @@ -1,6 +1,7 @@ import 'babel-polyfill' import {prefixedClassNames, withPackageName, transformWithPrefix} from './lib/pacomo' -import React, {Component, PropTypes} from 'react' +import React, {Component} from 'react' +import PropTypes from 'prop-types' import TestUtils from 'react-addons-test-utils' import assert from 'assert' @@ -16,7 +17,7 @@ const { transformer, decorator } = withPackageName('prefix') function shallowRenderElement(element) { const shallowRenderer = TestUtils.createRenderer() shallowRenderer.render(element) - return shallowRenderer.getRenderOutput() + return shallowRenderer.getRenderOutput() } function shallowRenderComponent(Component, props) { From 15dc5e628ae69fec04da77d35048b40bd3b07d72 Mon Sep 17 00:00:00 2001 From: Ankur Taxali Date: Thu, 21 Dec 2017 12:43:51 +0530 Subject: [PATCH 3/3] React 15 does not recognize the `data-pacomoSkip` prop on a DOM element. Spell it as lowercase `data-pacomoskip` instead. --- src/pacomo.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pacomo.js b/src/pacomo.js index d5385d6..d799667 100644 --- a/src/pacomo.js +++ b/src/pacomo.js @@ -66,7 +66,7 @@ function transformElementProps(props, fn, childrenOnly) { function cloneElementWithSkip(element) { - return cloneElement(element, {'data-pacomoSkip': true}) + return cloneElement(element, {'data-pacomoskip': true}) } @@ -84,7 +84,7 @@ export function transformWithPrefix(prefix) { // // Optionally prefix with a `rootClass` and postfix with `suffixClass`. function transform(element, rootClass, suffixClasses='') { - if (typeof element !== 'object' || element.props['data-pacomoSkip']) return element + if (typeof element !== 'object' || element.props['data-pacomoskip']) return element const changes = transformElementProps( element.props,