-
Notifications
You must be signed in to change notification settings - Fork 48.8k
[React DevTools] Improve DevTools UI when Inspecting a user Component that Throws an Error #24248
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
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b4a8d91
[ReactDevTools] custom view for errors occur in user's code
mondaychen ce3cea5
[ReactDevTools] show message for unsupported feature
mondaychen 8fecbd4
fix bad import
mondaychen 7344311
fix typo
mondaychen 4c34e7e
fix issues from rebasing
mondaychen 102ba98
prettier
mondaychen 84a8557
sync error names
mondaychen 15e57f4
sync error name with upstream
mondaychen 05505f8
fix lint & better comment
mondaychen 1da5e17
fix error message for test
mondaychen 3862f3e
better error message per review
mondaychen b7ecfdf
add missing file
mondaychen 5edaca4
remove dead enum & provide component name in error message
mondaychen 2eda867
better error message
mondaychen 65a2c90
better user facing error message
mondaychen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/react-devtools-shared/src/devtools/views/ErrorBoundary/CaughtErrorView.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import * as React from 'react'; | ||
import styles from './shared.css'; | ||
|
||
type Props = {| | ||
callStack: string | null, | ||
children: React$Node, | ||
info: React$Node | null, | ||
componentStack: string | null, | ||
errorMessage: string, | ||
|}; | ||
|
||
export default function CaughtErrorView({ | ||
callStack, | ||
children, | ||
info, | ||
componentStack, | ||
errorMessage, | ||
}: Props) { | ||
return ( | ||
<div className={styles.ErrorBoundary}> | ||
{children} | ||
<div className={styles.ErrorInfo}> | ||
<div className={styles.HeaderRow}> | ||
<div className={styles.ErrorHeader}>{errorMessage}</div> | ||
</div> | ||
{!!info && <div className={styles.InfoBox}>{info}</div>} | ||
{!!callStack && ( | ||
<div className={styles.ErrorStack}> | ||
The error was thrown {callStack.trim()} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
21 changes: 21 additions & 0 deletions
21
packages/react-devtools-shared/src/errors/UnknownHookError.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export default class UnknownHookError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
|
||
// Maintains proper stack trace for where our error was thrown (only available on V8) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, UnknownHookError); | ||
} | ||
|
||
this.name = 'UnknownHookError'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export default class UserError extends Error { | ||
constructor(message: string) { | ||
super(message); | ||
|
||
// Maintains proper stack trace for where our error was thrown (only available on V8) | ||
if (Error.captureStackTrace) { | ||
Error.captureStackTrace(this, UserError); | ||
} | ||
|
||
this.name = 'UserError'; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.