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

Commit

Permalink
fix(umd): get PropTypes from global object if using UMD build
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Sep 25, 2017
1 parent 7c3e075 commit ea831b1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/react-compat.js
@@ -1,4 +1,5 @@
import React from 'react'
import codegen from 'codegen.macro'
import {isPreact} from './constants'

let PropTypes
Expand Down Expand Up @@ -77,7 +78,13 @@ if (isPreact) {
} else if (parseFloat(React.version.slice(0, 4)) >= 15.5) {
/* istanbul ignore next */
try {
PropTypes = require('prop-types')
PropTypes = codegen`
if (process.env.BUILD_FORMAT === 'umd') {
module.exports = "(typeof window !== 'undefined' ? window : global).PropTypes"
} else {
module.exports = "require('prop-types')"
}
`
/* istanbul ignore next */
} catch (error) {
// ignore
Expand Down

0 comments on commit ea831b1

Please sign in to comment.