Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clearing console when Panel mounted may leads to unexpected behavior. #25

Open
hanezu opened this issue Jul 14, 2020 · 2 comments
Open

Comments

@hanezu
Copy link
Contributor

hanezu commented Jul 14, 2020

On this line, if debug is set to the default value false, this line will clear all console messages prior to the point the Panel component is mounted.

As a result, some user-defined console messages in e.g. src/main.js will be ignored. This is quite unexpected and should be removed or at least substituted as a separate prop.

For example, we can add a clearConsole as a prop, with a default value false, and change the line to if (this.clearConsole) console.clear();

@Inventsable
Copy link
Member

Good point! Would you be against <Panel keep-console />? The reason I personally like the default behavior is that it refreshes and resets the console on hot reload or refreshing. Many components also have a hidden debug prop which logs additional information on changes inside the component which, when set would also remove the console.clear. I'll be doing some updates to components today and will put this prop in unless I hear otherwise

@hanezu
Copy link
Contributor Author

hanezu commented Jul 15, 2020

Would you be against <Panel keep-console />?

I can see why you prefer clearing the console by default.
However, I would like to say that keep-console does not sound like a good idea to me.

In my case, I wrote a buggy line that executed before Panel is mounted. It threw an error, but I couldn't see the error in the console.

I later realized the bug and changed to <Panel debug />. It does print some extra debugging lines, but all I did is simply ignored them. So adding a keep-console does not add more to the current debug prop.

Besides, although clearing the console can reset the console on hot reload or refreshing, as a default behavior it should be called immediately after javascript is loaded, so that no errors will be ignored.

One solution to this problem may be using console.debug instead of console.log, so you can debug the UI components while users will not see these logs in console by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants