forked from facebook/react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store throws a specific Error type (UnsupportedBridgeOperationError) (f…
…acebook#24147) When this Error type is detected, DevTools shows a custom error overlay with upgrade/downgrade instructions.
- Loading branch information
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
packages/react-devtools-shared/src/UnsupportedBridgeOperationError.js
This file contains 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 UnsupportedBridgeOperationError 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, UnsupportedBridgeOperationError); | ||
} | ||
|
||
this.name = 'UnsupportedBridgeOperationError'; | ||
} | ||
} |
This file contains 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 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
50 changes: 50 additions & 0 deletions
50
.../react-devtools-shared/src/devtools/views/ErrorBoundary/UnsupportedBridgeOperationView.js
This file contains 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,50 @@ | ||
/** | ||
* 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, | ||
componentStack: string | null, | ||
errorMessage: string | null, | ||
|}; | ||
|
||
export default function UnsupportedBridgeOperationView({ | ||
callStack, | ||
children, | ||
componentStack, | ||
errorMessage, | ||
}: Props) { | ||
return ( | ||
<div className={styles.ErrorBoundary}> | ||
{children} | ||
<div className={styles.ErrorInfo}> | ||
<div className={styles.HeaderRow}> | ||
<div className={styles.ErrorHeader}> | ||
{errorMessage || 'Bridge protocol mismatch'} | ||
</div> | ||
</div> | ||
<div className={styles.InfoBox}> | ||
An incompatible version of <code>react-devtools-core</code> has been | ||
embedded in a renderer like React Native. To fix this, update the{' '} | ||
<code>react-devtools-core</code> package within the React Native | ||
application, or downgrade the <code>react-devtools</code> package you | ||
use to open the DevTools UI. | ||
</div> | ||
{!!callStack && ( | ||
<div className={styles.ErrorStack}> | ||
The error was thrown {callStack.trim()} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains 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