Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Commit

Permalink
fix(react): add react-compat to deal with the warnings
Browse files Browse the repository at this point in the history
React@15.5.0 introduced deprecation warnings for a few things and
they're really annoying. So this will help prevent those warnings from
logging for people using this package.
  • Loading branch information
Kent C. Dodds committed Apr 9, 2017
1 parent 7623088 commit de50b7c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 89 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ as well (if you don't already have them):
npm install --save react glamor
```

> NOTE: If you're using React v15.5 or greater, you'll also need to have
> `prop-types` installed: `npm install --save prop-types`
You can then use one of the module formats:

- `main`: `dist/glamorous.cjs.js` - exports itself as a CommonJS module
Expand Down Expand Up @@ -132,6 +135,7 @@ If you want to use the global:
```html
<!-- Load dependencies -->
<script src="https://unpkg.com/react/dist/react.js"></script>
<script src="https://unpkg.com/prop-types/prop-types.js"></script>
<script src="https://unpkg.com/glamor/umd/index.js"></script>
<!-- load library -->
<script src="https://unpkg.com/glamorous/dist/glamorous.umd.js"></script>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
"nps-utils": "^1.1.2",
"opt-cli": "^1.5.1",
"prettier-eslint-cli": "^3.1.2",
"prop-types": "^15.5.6",
"react": "^15.5.3",
"react-addons-test-utils": "^15.5.1",
"react-dom": "^15.5.3",
Expand Down
3 changes: 2 additions & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ export default {
exports: 'default',
moduleName: 'glamorous',
format: 'umd',
external: ['react', 'glamor'],
external: ['react', 'glamor', 'prop-types'],
globals: {
react: 'React',
glamor: 'Glamor',
'prop-types': 'PropTypes',
},
plugins: [
nodeResolve({jsnext: true, main: true}),
Expand Down
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import React from 'react'
import {css, styleSheet} from 'glamor'
import shouldForwardProperty from './should-forward-property'
import domElements from './dom-elements'

const {PropTypes} = React
import {PropTypes} from './react-compat'

/**
* This is the main export and the function that people
Expand Down
19 changes: 19 additions & 0 deletions src/react-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint import/no-mutable-exports:0, import/prefer-default-export:0 */
import React from 'react'

let PropTypes

/* istanbul ignore next */
if (React.version.slice(0, 4) === '15.5') {
/* istanbul ignore next */
try {
PropTypes = require('prop-types')
/* istanbul ignore next */
} catch (error) {
// ignore
}
}
/* istanbul ignore next */
PropTypes = PropTypes || React.PropTypes

export {PropTypes}
95 changes: 9 additions & 86 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -347,31 +347,7 @@ babel-code-frame@6.22.0, babel-code-frame@^6.16.0, babel-code-frame@^6.22.0:
esutils "^2.0.2"
js-tokens "^3.0.0"

babel-core@6, babel-core@^6.0.0:
version "6.24.0"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.0.tgz#8f36a0a77f5c155aed6f920b844d23ba56742a02"
dependencies:
babel-code-frame "^6.22.0"
babel-generator "^6.24.0"
babel-helpers "^6.23.0"
babel-messages "^6.23.0"
babel-register "^6.24.0"
babel-runtime "^6.22.0"
babel-template "^6.23.0"
babel-traverse "^6.23.1"
babel-types "^6.23.0"
babylon "^6.11.0"
convert-source-map "^1.1.0"
debug "^2.1.1"
json5 "^0.5.0"
lodash "^4.2.0"
minimatch "^3.0.2"
path-is-absolute "^1.0.0"
private "^0.1.6"
slash "^1.0.0"
source-map "^0.5.0"

babel-core@^6.24.1:
babel-core@6, babel-core@^6.0.0, babel-core@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83"
dependencies:
Expand Down Expand Up @@ -404,20 +380,7 @@ babel-eslint@^7.2.0:
babel-types "^6.23.0"
babylon "^6.16.1"

babel-generator@^6.18.0, babel-generator@^6.24.0:
version "6.24.0"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.0.tgz#eba270a8cc4ce6e09a61be43465d7c62c1f87c56"
dependencies:
babel-messages "^6.23.0"
babel-runtime "^6.22.0"
babel-types "^6.23.0"
detect-indent "^4.0.0"
jsesc "^1.3.0"
lodash "^4.2.0"
source-map "^0.5.0"
trim-right "^1.0.1"

babel-generator@^6.24.1:
babel-generator@^6.18.0, babel-generator@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497"
dependencies:
Expand Down Expand Up @@ -592,13 +555,6 @@ babel-helper-replace-supers@^6.22.0, babel-helper-replace-supers@^6.23.0:
babel-traverse "^6.23.0"
babel-types "^6.23.0"

babel-helpers@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.23.0.tgz#4f8f2e092d0b6a8808a4bde79c27f1e2ecf0d992"
dependencies:
babel-runtime "^6.22.0"
babel-template "^6.23.0"

babel-helpers@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2"
Expand Down Expand Up @@ -1052,7 +1008,7 @@ babel-preset-stage-3@^6.24.1:
babel-plugin-transform-exponentiation-operator "^6.24.1"
babel-plugin-transform-object-rest-spread "^6.22.0"

babel-register@^6.24.0, babel-register@^6.24.1:
babel-register@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f"
dependencies:
Expand All @@ -1071,17 +1027,7 @@ babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0:
core-js "^2.4.0"
regenerator-runtime "^0.10.0"

babel-template@^6.16.0, babel-template@^6.22.0, babel-template@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.23.0.tgz#04d4f270adbb3aa704a8143ae26faa529238e638"
dependencies:
babel-runtime "^6.22.0"
babel-traverse "^6.23.0"
babel-types "^6.23.0"
babylon "^6.11.0"
lodash "^4.2.0"

babel-template@^6.24.1:
babel-template@^6.16.0, babel-template@^6.22.0, babel-template@^6.23.0, babel-template@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333"
dependencies:
Expand All @@ -1091,21 +1037,7 @@ babel-template@^6.24.1:
babylon "^6.11.0"
lodash "^4.2.0"

babel-traverse@^6.18.0, babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1:
version "6.23.1"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.23.1.tgz#d3cb59010ecd06a97d81310065f966b699e14f48"
dependencies:
babel-code-frame "^6.22.0"
babel-messages "^6.23.0"
babel-runtime "^6.22.0"
babel-types "^6.23.0"
babylon "^6.15.0"
debug "^2.2.0"
globals "^9.0.0"
invariant "^2.2.0"
lodash "^4.2.0"

babel-traverse@^6.24.1:
babel-traverse@^6.18.0, babel-traverse@^6.22.0, babel-traverse@^6.23.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695"
dependencies:
Expand All @@ -1119,16 +1051,7 @@ babel-traverse@^6.24.1:
invariant "^2.2.0"
lodash "^4.2.0"

babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0:
version "6.23.0"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.23.0.tgz#bb17179d7538bad38cd0c9e115d340f77e7e9acf"
dependencies:
babel-runtime "^6.22.0"
esutils "^2.0.2"
lodash "^4.2.0"
to-fast-properties "^1.0.1"

babel-types@^6.24.1:
babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.22.0, babel-types@^6.23.0, babel-types@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975"
dependencies:
Expand Down Expand Up @@ -4076,15 +3999,15 @@ lodash.some@^4.4.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/lodash.some/-/lodash.some-4.6.0.tgz#1bb9f314ef6b8baded13b549169b2a945eb68e4d"

lodash@4.17.2, lodash@^4.0.0, lodash@^4.17.2:
lodash@4.17.2:
version "4.17.2"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42"

lodash@^3.6.0:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"

lodash@^4.11.2, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.5.1:
lodash@^4.0.0, lodash@^4.11.2, lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.2, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.5.1:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

Expand Down Expand Up @@ -4989,7 +4912,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@^15.5.2, prop-types@~15.5.0:
prop-types@^15.5.2, prop-types@^15.5.6, prop-types@~15.5.0:
version "15.5.6"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.6.tgz#797a915b1714b645ebb7c5d6cc690346205bd2aa"
dependencies:
Expand Down

0 comments on commit de50b7c

Please sign in to comment.