Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 48bed04

Browse filesBrowse files
committed
refactor: improve 'unregistered icon' error message
1 parent 7bcf299 commit 48bed04
Copy full SHA for 48bed04

File tree

1 file changed

+10
-4
lines changed
Filter options

1 file changed

+10
-4
lines changed

‎src/CIcon.js

Copy file name to clipboardExpand all lines: src/CIcon.js
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@ import PropTypes from 'prop-types'
33
import classNames from 'classnames'
44
import './CIcon.css'
55

6-
const colog = (...args) => {
7-
if (process && process.env && process.env.NODE_ENV === 'development') {
8-
console.warn(...args)
6+
let warned = {}
7+
const colog = (msg, icon) => {
8+
if (!warned[icon] && process && process.env && process.env.NODE_ENV === 'development') {
9+
warned[icon] = true
10+
console.error(msg)
911
}
1012
}
1113

@@ -46,7 +48,11 @@ const CIcon = props => {
4648
return content
4749
} else if (name && React.icons) {
4850
return React.icons[iconName] ? React.icons[iconName] :
49-
colog('Not existing icon: '+ iconName + ' in React.icons object')
51+
colog(`CIcon component: icon name '${iconName}' does not exist in React.icons object. ` +
52+
`To use icons by 'name' prop you need to make them available globally ` +
53+
`by adding them to React.icons object. CIcon component docs: https://coreui.io/react/docs/components/CIcon \n`,
54+
iconName
55+
)
5056
}
5157
}, [change])
5258

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.