Skip to content
This repository has been archived by the owner on Aug 28, 2022. It is now read-only.

Consume PropTypes from the prop-types module #61

Merged
merged 4 commits into from
Jul 31, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"semantic-release": "^6.3.6"
},
"dependencies": {
"brcast": "^2.0.0"
"brcast": "^2.0.0",
"prop-types": "^15.5.10"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally we might opt to put this in peerDependencies, but since it's an optional dependency, let's follow glamorous and place this in devDependencies

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

},
"eslintConfig": {
"extends": [
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint func-style:0, react/prop-types:0 */
import 'react-native-mock-render/mock' // eslint-disable-line
import React from 'react'
import PropTypes from 'prop-types'
import {StyleSheet, View} from 'react-native'
import renderer from 'react-test-renderer'
import {shallow} from 'enzyme'
Expand Down Expand Up @@ -375,7 +376,7 @@ it('should accept user defined contextTypes', () => {
const dynamicStyles = jest.fn()
const Child = glamorous.view(dynamicStyles)
Child.contextTypes = {
fontSize: React.PropTypes.number,
fontSize: PropTypes.number,
}

const context = {
Expand Down
3 changes: 2 additions & 1 deletion src/__tests__/with-theme.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint func-style:0, react/prop-types:0 */
import React, {PropTypes} from 'react'
import React from 'react'
import PropTypes from 'prop-types'
import {View} from 'react-native'
import renderer from 'react-test-renderer'

Expand Down
3 changes: 2 additions & 1 deletion src/create-glamorous.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, {PropTypes} from 'react'
import React from 'react'
import {StyleSheet} from 'react-native'
import {CHANNEL} from './constants'
import getStyles from './get-styles'
import PropTypes from './react-compat'

function prepareStyles(styles) {
return styles.filter(style => {
Expand Down
15 changes: 15 additions & 0 deletions src/react-compat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'

// eslint-disable-next-line import/no-mutable-exports
let PropTypes

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

export default PropTypes
3 changes: 2 additions & 1 deletion src/theme-provider.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {PropTypes} from 'react'
import React from 'react'
import brcast from 'brcast'
import {CHANNEL} from './constants'
import PropTypes from './react-compat'

export default class ThemeProvider extends React.Component {
static childContextTypes = {
Expand Down
3 changes: 2 additions & 1 deletion src/with-theme.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {PropTypes} from 'react'
import React from 'react'
import {CHANNEL} from './constants'
import PropTypes from './react-compat'

function generateWarningMessage(componentName) {
// eslint-disable-next-line max-len
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5089,7 +5089,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@^15.5.4, prop-types@~15.5.7:
prop-types@^15.5.10, prop-types@^15.5.4, prop-types@~15.5.7:
version "15.5.10"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154"
dependencies:
Expand Down