-
Notifications
You must be signed in to change notification settings - Fork 45.6k
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
Remove React.error and React.warn #16126
Conversation
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.
I love the proposed solution to auto-attach stacks. Solidddd.
React: size: -0.2%, gzip: -0.4% Details of bundled changes.Comparing: 29b4559...adce079 react
Generated by 🚫 dangerJS |
While this does sound like a good solution for experienced developers it still requires additional setup and navigation for novice developers. Debugging react shouldn't require a separate extension for the most basic things (like a "call"stack). Is this really just removed because some rogue libraries might parse the component stack? Should we really optimize against possible hacks instead of for "normal" users? |
React DevTools are not just for "experienced developers" but all levels 😄 The component stack, while very helpful, is not required for debugging React apps. (It hasn't existed up until this point, after all.)
No. I linked to #16017 which specifies a few concerns. Probably my biggest at this moment is that overriding only these two console methods also feels like an incomplete solution to the larger logging story (#15726). |
I was concerned with the existing setup. If I start out with react it's highly unlikely I have the devtools set up.
I'm not sure about the specific timeline but it existed for a long time in react itself (react specific warnings or prop-types). I fear this change is too tunnel visioned on react-devtools only. It doesn't ship in the browser by default. |
In this scenario, the first time you ran React in development mode you would see this message in the console:
The thing that has not existed (because we never actually released these APIs) is the ability to log custom errors or warnings in user land with component stacks attached. There's a balance to be struct between adding more things to React (which adds weight to the framework, even for the majority of people who use React apps and are not developers) and adding things to the surrounding tooling (which is opt-in and only impacts developers). We don't make decisions like this lightly. There were several rounds of conversation between various parts of the team, and a couple of proposals (written by me). There is also still an outstanding issue (linked to in this PR) to come up with a more comprehensive logging plan. This decision feels like the right set of trade offs at this moment in time though (in preparation for the 16.9 release). |
@bvaughn Was this originally inspired by the warning and invariant? 😄 |
@babangsund Not directly, not really. More so by |
Summary: T46547044 has been closed and apparently `React.warn` was removed in [facebook#16126](facebook/react#16126). Changelog: [Internal] Reviewed By: cortinico Differential Revision: D52907508
Summary: T46547044 has been closed and apparently `React.warn` was removed in [facebook#16126](facebook/react#16126). Changelog: [Internal] Reviewed By: cortinico Differential Revision: D52907508
Summary: Pull Request resolved: #42395 T46547044 has been closed and apparently `React.warn` was removed in [#16126](facebook/react#16126). Changelog: [Internal] Reviewed By: cortinico Differential Revision: D52907508 fbshipit-source-id: a3621d876f904339791ab184a904e81f7a50b988
Sebastian and I have just discussed my concerns around
React.warn
andReact.error
. The quick takeaway is this: I am going to removeReact.warn
andReact.error
for now. We can revisit these methods later as part of a larger discussion around the console logging experience with React (see #15726) but we should not block 16.9 for this.In the meanwhile, I will be adding functionality to React DevTools to intercept calls to
console.error
,console.warn
, andconsole.trace
and auto-append component stacks (in DEV mode). This seems like a nice 80/20 solution that doesn't limit our options for a future API.