-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: This diff adds a new `unstable_enableLogBox` function to opt-into the new LogBox experience. If LogBox is not enabled early enough, we show an error with instructions. With this, LogBox can be enabled with: ``` require('react-native').unstable_enableLogBox(); ``` Changelog: [General] [Adds] unstable_enableLogBox Reviewed By: zackargyle, rubennorte Differential Revision: D18808940 fbshipit-source-id: 4b0234ddc4d1646515bf63110d5b02133780512e
- Loading branch information
1 parent
5879795
commit dd8e5f4
Showing
8 changed files
with
189 additions
and
62 deletions.
There are no files selected for viewing
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
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
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,65 @@ | ||
/** | ||
* 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 | ||
* @format | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const React = require('react'); | ||
|
||
import type {Category} from './Data/YellowBoxCategory'; | ||
import type {Registry, Subscription} from './Data/YellowBoxRegistry'; | ||
|
||
type Props = $ReadOnly<{||}>; | ||
type State = $ReadOnly<{| | ||
registry: ?Registry, | ||
|}>; | ||
|
||
const YellowBoxList = require('./UI/YellowBoxList'); | ||
const YellowBoxRegistry = require('./Data/YellowBoxRegistry'); | ||
|
||
class YellowBoxContainer extends React.Component<Props, State> { | ||
_subscription: ?Subscription; | ||
|
||
state: State = { | ||
registry: null, | ||
}; | ||
|
||
render(): React.Node { | ||
// TODO: Ignore warnings that fire when rendering `YellowBox` itself. | ||
return this.state.registry == null ? null : ( | ||
<YellowBoxList | ||
onDismiss={this._handleDismiss} | ||
onDismissAll={this._handleDismissAll} | ||
registry={this.state.registry} | ||
/> | ||
); | ||
} | ||
|
||
componentDidMount(): void { | ||
this._subscription = YellowBoxRegistry.observe(registry => { | ||
this.setState({registry}); | ||
}); | ||
} | ||
|
||
componentWillUnmount(): void { | ||
if (this._subscription != null) { | ||
this._subscription.unsubscribe(); | ||
} | ||
} | ||
|
||
_handleDismiss = (category: Category): void => { | ||
YellowBoxRegistry.delete(category); | ||
}; | ||
|
||
_handleDismissAll(): void { | ||
YellowBoxRegistry.clear(); | ||
} | ||
} | ||
|
||
export default YellowBoxContainer; |
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
5 changes: 5 additions & 0 deletions
5
Libraries/YellowBox/__tests__/__snapshots__/YellowBox-test.js.snap
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,5 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`YellowBox should render LogBoxNotificationContainer when LogBox is enabled 1`] = `<LogBoxNotificationContainer />`; | ||
|
||
exports[`YellowBox should render YellowBoxContainer by default 1`] = `<YellowBoxContainer />`; |
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