Skip to content

Expose DEV-mode warnings in devtools UI #9189

Closed
@bvaughn

Description

@bvaughn

React has made recent developer experience improvements to lifecycle error handling and logging. Errors thrown during render can be recovered from using unstable_handleError componentDidCatch. Errors thrown during lifecycle methods are also automatically logged to the console with the component stack location to make them easier to identify (see #8785).

The team has discussed similar improvements for warnings- such as using a "yellow box" approach to make warnings stand out more in developer mode (see PRs #7360 and #8861). There has been some pushback though to the idea of React modifying the DOM for warning purposes (see issue #8784). I'm not sure how that will play out yet- but in the meanwhile, could we improve at least some of these use cases by making better use of the devtools?

For example, what if React exposed a new API that allowed associating a warning with one or more components in the devtools panel? (eg a method that- when called- recorded the current component stack and notified devtools if present) React could use this for things like missing or non-unique keys. 3rd party libraries may also benefit from this (eg react-virtualized could use this to warn about missing or incomplete positioning styles for cells).

Here's a rough outline of some of the features:

  • Components with warnings could be highlighted in some emphasized way (eg yellow background) in devtools to make them easier to spot.
  • A new toolbar option could be added to "Show All Warnings" (eg filter the tree view to show only components with warnings).
  • Warning message could be shown inline in the settings panel for the selected component.

Here's a rough mockup:
screen shot 2017-03-15 at 3 47 31 pm

Limitations:

  • Not everyone uses devtools so this would not help a lot of people.
  • This would not address issues like using the development mode of React for production sites.

Thoughts? Ideas? Suggestions?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions