( type: Function, fallbackName: string = 'Anonymous', )
| 144 | } |
| 145 | |
| 146 | export function getDisplayName( |
| 147 | type: Function, |
| 148 | fallbackName: string = 'Anonymous', |
| 149 | ): string { |
| 150 | const nameFromCache = cachedDisplayNames.get(type); |
| 151 | if (nameFromCache != null) { |
| 152 | return nameFromCache; |
| 153 | } |
| 154 | |
| 155 | let displayName = fallbackName; |
| 156 | |
| 157 | // The displayName property is not guaranteed to be a string. |
| 158 | // It's only safe to use for our purposes if it's a string. |
| 159 | // github.com/facebook/react-devtools/issues/803 |
| 160 | if (typeof type.displayName === 'string') { |
| 161 | displayName = type.displayName; |
| 162 | } else if (typeof type.name === 'string' && type.name !== '') { |
| 163 | displayName = type.name; |
| 164 | } |
| 165 | |
| 166 | cachedDisplayNames.set(type, displayName); |
| 167 | return displayName; |
| 168 | } |
| 169 | |
| 170 | let uidCounter: number = 0; |
| 171 |
no test coverage detected