mirror of
https://github.com/status-im/react-navigation.git
synced 2025-02-24 17:18:09 +00:00
Show screen props warning only once. Fixes #258
This commit is contained in:
parent
73426e8015
commit
1f80d98112
@ -11,11 +11,12 @@ import type {
|
||||
|
||||
type Props = {
|
||||
screenProps?: {};
|
||||
hideScreenPropsWarning?: boolean;
|
||||
navigation: NavigationScreenProp<NavigationState, NavigationAction>;
|
||||
component: ReactClass<*>;
|
||||
};
|
||||
|
||||
let screenPropsWarningShown = false;
|
||||
|
||||
export default class SceneView extends PureComponent<void, Props, void> {
|
||||
static childContextTypes = {
|
||||
navigation: React.PropTypes.object.isRequired,
|
||||
@ -30,18 +31,18 @@ export default class SceneView extends PureComponent<void, Props, void> {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
if (this.props.screenProps !== undefined && !this.props.hideScreenPropsWarning) {
|
||||
if (this.props.screenProps !== undefined && !screenPropsWarningShown) {
|
||||
console.warn(
|
||||
'Behaviour of screenProps has changed from initial beta. ' +
|
||||
'Components will now receive it as `this.props.screenProps` instead.\n' +
|
||||
'Pass `hideScreenPropsWarning` to hide this warning.'
|
||||
'This warning will be removed in future.'
|
||||
);
|
||||
screenPropsWarningShown = true;
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
hideScreenPropsWarning,
|
||||
screenProps,
|
||||
navigation,
|
||||
component: Component,
|
||||
@ -49,7 +50,6 @@ export default class SceneView extends PureComponent<void, Props, void> {
|
||||
|
||||
return (
|
||||
<Component
|
||||
hideScreenPropsWarning={hideScreenPropsWarning}
|
||||
screenProps={screenProps}
|
||||
navigation={navigation}
|
||||
/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user