Skip to content

Commit 5c39d0f

Browse files
committed
ZulipStatusBar: Fix types in connect call.
Some changes I was experimenting with somehow inspired Flow to start pointing out things like Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ src/common/ZulipStatusBar.js:71:20 Property backgroundColor is missing in props [1]. src/common/ZulipStatusBar.js 68│ export default connect((state, props) => ({ 69│ safeAreaInsets: getSession(state).safeAreaInsets, 70│ theme: getSettings(state).theme, 71│ backgroundColor: props.backgroundColor || getTitleBackgroundColor(props.narrow)(state), 72│ orientation: getSession(state).orientation, 73│ }))(ZulipStatusBar); 74│ src/chat/ChatScreen.js [1] 36│ <ZulipStatusBar narrow={narrow} /> Where indeed, that code uses `props.backgroundColor` in a way that looks like it assumes such a prop is present. It doesn't really, but that's hard to tell without more context. Make the logic more explicit, which fixed those errors. As a bonus, the two remaining "ST is not a React component" errors go away too!
1 parent 2410627 commit 5c39d0f

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

src/common/Screen.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class Screen extends PureComponent<Props> {
113113

114114
return (
115115
<View style={[contextStyles.screen, { paddingBottom: safeAreaInsets.bottom }]}>
116-
{/* $FlowFixMe-56 Cannot create ZulipStatusBar element because ST is not a React component. */}
117116
<ZulipStatusBar />
118117
{search ? (
119118
<ModalSearchNavBar autoFocus={autoFocus} searchBarOnChange={searchBarOnChange} />

src/common/ZulipStatusBar.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React, { PureComponent } from 'react';
55
import { Platform, StatusBar, View } from 'react-native';
66
import Color from 'color';
77

8-
import type { Dimensions, ThemeName } from '../types';
8+
import type { Dimensions, GlobalState, Narrow, ThemeName } from '../types';
99
import { DEFAULT_TITLE_BACKGROUND_COLOR, getTitleBackgroundColor } from '../title/titleSelectors';
1010
import { foregroundColorFromBackground } from '../utils/color';
1111
import { getSession, getSettings } from '../selectors';
@@ -65,9 +65,14 @@ class ZulipStatusBar extends PureComponent<Props> {
6565
}
6666
}
6767

68-
export default connect((state, props) => ({
69-
safeAreaInsets: getSession(state).safeAreaInsets,
70-
theme: getSettings(state).theme,
71-
backgroundColor: props.backgroundColor || getTitleBackgroundColor(props.narrow)(state),
72-
orientation: getSession(state).orientation,
73-
}))(ZulipStatusBar);
68+
export default connect(
69+
(state: GlobalState, props: { backgroundColor?: string, narrow?: Narrow }) => ({
70+
safeAreaInsets: getSession(state).safeAreaInsets,
71+
theme: getSettings(state).theme,
72+
backgroundColor:
73+
props.backgroundColor !== undefined
74+
? props.backgroundColor
75+
: getTitleBackgroundColor(props.narrow)(state),
76+
orientation: getSession(state).orientation,
77+
}),
78+
)(ZulipStatusBar);

src/main/MainScreenWithTabs.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export default class MainScreenWithTabs extends PureComponent<{}> {
1919

2020
return (
2121
<View style={[styles.flexed, contextStyles.backgroundColor]}>
22-
{/* $FlowFixMe-56 Cannot create ZulipStatusBar element because ST is not a React component. */}
2322
<ZulipStatusBar />
2423
<OfflineNotice />
2524
<MainTabs />

0 commit comments

Comments
 (0)