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 7, 2017
1 parent 47c26e0 commit 6d3a324
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 272 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://packd.now.sh/prop-types?name=PropTypes"></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
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@
"nps-utils": "^1.1.2",
"opt-cli": "^1.5.1",
"prettier-eslint-cli": "^3.1.2",
"react": "^15.4.2",
"react-addons-test-utils": "^15.4.2",
"react-dom": "^15.4.2",
"prop-types": "^15.5.1",
"react": "^15.5.1",
"react-addons-test-utils": "^15.5.0",
"react-dom": "^15.5.1",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-commonjs": "^8.0.2",
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
14 changes: 14 additions & 0 deletions src/react-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* 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') {
PropTypes = require('prop-types')
/* istanbul ignore next */
} else {
PropTypes = React.PropTypes
}

export {PropTypes}
Loading

0 comments on commit 6d3a324

Please sign in to comment.