[change] don't use invariant in StyleSheet validation

This commit is contained in:
Nicolas Gallagher
2016-07-11 00:01:29 -07:00
parent 61860b6d49
commit 179d624917
+7 -6
View File
@@ -10,7 +10,7 @@ import { PropTypes } from 'react'
import ImageStylePropTypes from '../../components/Image/ImageStylePropTypes' import ImageStylePropTypes from '../../components/Image/ImageStylePropTypes'
import TextStylePropTypes from '../../components/Text/TextStylePropTypes' import TextStylePropTypes from '../../components/Text/TextStylePropTypes'
import ViewStylePropTypes from '../../components/View/ViewStylePropTypes' import ViewStylePropTypes from '../../components/View/ViewStylePropTypes'
import invariant from 'fbjs/lib/invariant' import warning from 'fbjs/lib/warning'
class StyleSheetValidation { class StyleSheetValidation {
static validateStyleProp(prop, style, caller) { static validateStyleProp(prop, style, caller) {
@@ -19,10 +19,11 @@ class StyleSheetValidation {
const message1 = `"${prop}" is not a valid style property.` const message1 = `"${prop}" is not a valid style property.`
const message2 = '\nValid style props: ' + JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' ') const message2 = '\nValid style props: ' + JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' ')
styleError(message1, style, caller, message2) styleError(message1, style, caller, message2)
} } else {
const error = allStylePropTypes[prop](style, prop, caller, 'prop') const error = allStylePropTypes[prop](style, prop, caller, 'prop')
if (error) { if (error) {
styleError(error.message, style, caller) styleError(error.message, style, caller)
}
} }
} }
} }
@@ -43,7 +44,7 @@ class StyleSheetValidation {
} }
const styleError = (message1, style, caller, message2) => { const styleError = (message1, style, caller, message2) => {
invariant( warning(
false, false,
message1 + '\n' + (caller || '<<unknown>>') + ': ' + message1 + '\n' + (caller || '<<unknown>>') + ': ' +
JSON.stringify(style, null, ' ') + (message2 || '') JSON.stringify(style, null, ' ') + (message2 || '')