From 78686ef7aea757a08ebce5aaf018b85459ad01a0 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Thu, 4 Apr 2019 12:52:07 -0700 Subject: [PATCH] wip Screen: fix props types Thanks to facebook/flow#6906 for this `Partial` type -- a workaround for `$Shape` not working correctly. See also facebook/flow#7298. --- src/common/Screen.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/common/Screen.js b/src/common/Screen.js index 650af88765b..8952f4e3c36 100644 --- a/src/common/Screen.js +++ b/src/common/Screen.js @@ -29,16 +29,11 @@ const componentStyles = StyleSheet.create({ }, }); -type Props = {| - dispatch: Dispatch, +type DefaultedProps = {| centerContent: boolean, - +children: React$Node, - safeAreaInsets: Dimensions, keyboardShouldPersistTaps: 'never' | 'always' | 'handled', padding: boolean, scrollEnabled: boolean, - style?: Style, - search: boolean, autoFocus: boolean, searchBarOnChange: (text: string) => void, @@ -47,6 +42,22 @@ type Props = {| +title: LocalizableText, |}; +type DirectProps = {| + +children: React$Node, + style?: Style, +|}; + +type ReduxProps = {| + dispatch: Dispatch, + safeAreaInsets: Dimensions, +|}; + +type Partial = $Rest; + +type OuterProps = {| ...Partial, ...DirectProps |}; + +type Props = {| ...DefaultedProps, ...DirectProps, ...ReduxProps |}; + /** * Wrapper component for each screen of the app, for consistent look-and-feel. * @@ -137,6 +148,6 @@ class Screen extends PureComponent { } } -export default connect((state: GlobalState) => ({ +export default connect<_, OuterProps, _, _, _, _>((state: GlobalState) => ({ safeAreaInsets: getSession(state).safeAreaInsets, }))(Screen);