(message: string, element: React.ReactNode)
| 26 | } |
| 27 | |
| 28 | function debugReportError(message: string, element: React.ReactNode) { |
| 29 | if (!enableDebugLog) return; |
| 30 | |
| 31 | if (!React.isValidElement(element)) { |
| 32 | console.error( |
| 33 | message, |
| 34 | `Invalid element: '${String(element)}' typeof=${typeof element}`, |
| 35 | ); |
| 36 | return; |
| 37 | } |
| 38 | |
| 39 | let sourceMessage = '<Unknown file>'; |
| 40 | try { |
| 41 | const elementWithSource = element as { |
| 42 | _source?: { fileName?: string; lineNumber?: number }; |
| 43 | }; |
| 44 | const fileName = elementWithSource._source?.fileName; |
| 45 | const lineNumber = elementWithSource._source?.lineNumber; |
| 46 | sourceMessage = fileName ? `${fileName}:${lineNumber}` : '<Unknown file>'; |
| 47 | } catch (error) { |
| 48 | console.error('Error while trying to get file name:', error); |
| 49 | } |
| 50 | |
| 51 | console.error(message, `${String(element.type)}. Source: ${sourceMessage}`); |
| 52 | } |
| 53 | interface MaxSizedBoxProps { |
| 54 | children?: React.ReactNode; |
| 55 | maxWidth?: number; |
no outgoing calls
no test coverage detected