2017-12-07 10:33:33 +00:00
|
|
|
import warning from 'warning'
|
|
|
|
|
|
|
|
const warned = {}
|
2017-12-26 11:04:28 +00:00
|
|
|
export default (valid, message, throwError) => {
|
2017-12-08 01:49:47 +00:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
if (!valid && !warned[message]) {
|
|
|
|
warning(false, message)
|
|
|
|
warned[message] = true
|
2017-12-26 11:04:28 +00:00
|
|
|
if (throwError) {
|
|
|
|
throw Error(message)
|
|
|
|
}
|
2017-12-08 01:49:47 +00:00
|
|
|
}
|
2017-12-07 10:33:33 +00:00
|
|
|
}
|
|
|
|
}
|