mirror of
https://github.com/zoriya/react-native-web.git
synced 2026-06-02 18:41:17 +00:00
[change] don't use invariant in StyleSheet validation
This commit is contained in:
@@ -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 || '')
|
||||||
|
|||||||
Reference in New Issue
Block a user