-
Notifications
You must be signed in to change notification settings - Fork 1
Remove logs from UI library #21
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,10 @@ | ||||||
"use client"; | ||||||
|
||||||
/** | ||||||
* @dev temporary removing some logs in client. | ||||||
*/ | ||||||
require("../../../tools/removeLogs"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can't use alias? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sadly no, it doesn't work in test ... Idk why. Look at my second commit. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you do
Suggested change
This don't works? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok when doing that I had an error saying that the file wasn't a module so I just added |
||||||
|
||||||
import Image from "next/image"; | ||||||
import styles from "./page.module.css"; | ||||||
import ThemeSelector from "@/components/ThemeSelector"; | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* @dev We are removing error and warning logs from `@ledgerhq/react-ui`. | ||
*/ | ||
const originalError = console.error; | ||
const originalWarn = console.warn; | ||
|
||
const EXCLUDED_ERRORS = [ | ||
"If you accidentally passed it from a parent component, remove it from the DOM element.", | ||
"You provided a `checked` prop to a form field without an `onChange` handler.", | ||
]; | ||
|
||
const EXCLUDED_WARNINGS = [ | ||
" is being sent through to the DOM, which will likely trigger a React console error.", | ||
]; | ||
|
||
console.error = (...args) => { | ||
const error = args.join(); | ||
if (EXCLUDED_ERRORS.some((excluded) => error.includes(excluded))) { | ||
return; | ||
} | ||
originalError.call(console, ...args); | ||
}; | ||
|
||
console.warn = (...args) => { | ||
const warning = args.join(); | ||
if (EXCLUDED_WARNINGS.some((excluded) => warning.includes(excluded))) { | ||
return; | ||
} | ||
originalWarn.call(console, ...args); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not mix require and import. You can use an import here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch