mirror of
https://github.com/zhigang1992/react.git
synced 2026-01-26 08:58:46 +08:00
19 lines
447 B
TypeScript
19 lines
447 B
TypeScript
const warningStack: { [key: string]: boolean } = {}
|
|
|
|
const useWarning = (message: string, component?: string) => {
|
|
const tag = component ? ` [${component}]` : ' '
|
|
const log = `[Geist UI]${tag}: ${message}`
|
|
|
|
if (typeof console === 'undefined') return
|
|
if (warningStack[log]) return
|
|
warningStack[log] = true
|
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
return console.error(log)
|
|
}
|
|
|
|
console.warn(log)
|
|
}
|
|
|
|
export default useWarning
|