mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-09 16:56:36 +02:00
Add utils/warning.js
This commit is contained in:
29
src/utils/warning.js
Normal file
29
src/utils/warning.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
const __DEV__ = (
|
||||||
|
typeof process !== 'undefined' &&
|
||||||
|
process.env &&
|
||||||
|
process.env.NODE_ENV !== 'production'
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log a development warning.
|
||||||
|
* @param {String} message
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default function warning(message) {
|
||||||
|
if (!__DEV__) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof console !== 'undefined') {
|
||||||
|
console.error('Warning: ', message) // eslint-disable-line no-console
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// --- Welcome to debugging Slate ---
|
||||||
|
// This error was thrown as a convenience so that you can use this stack
|
||||||
|
// to find the callsite that caused this warning to fire.
|
||||||
|
throw new Error(message)
|
||||||
|
} catch (x) {
|
||||||
|
// This error is only for debugging
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user