Skip to content

Commit

Permalink
wip Screen: fix props types
Browse files Browse the repository at this point in the history
Thanks to facebook/flow#6906 for this `Partial` type -- a workaround
for `$Shape` not working correctly.

See also facebook/flow#7298.
  • Loading branch information
gnprice committed Apr 5, 2019
1 parent 1127e31 commit b696cb2
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/common/Screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -47,6 +42,22 @@ type Props = {|
+title: LocalizableText,
|};

type DirectProps = {|
+children: React$Node,
style?: Style,
|};

type ReduxProps = {|
dispatch: Dispatch,
safeAreaInsets: Dimensions,
|};

type Partial<T> = $Rest<T, {}>;

type OuterProps = {| ...Partial<DefaultedProps>, ...DirectProps |};

type Props = {| ...DefaultedProps, ...DirectProps, ...ReduxProps |};

/**
* Wrapper component for each screen of the app, for consistent look-and-feel.
*
Expand Down Expand Up @@ -137,6 +148,6 @@ class Screen extends PureComponent<Props> {
}
}

export default connect((state: GlobalState) => ({
export default connect<_, OuterProps, _, _, _, _>((state: GlobalState) => ({
safeAreaInsets: getSession(state).safeAreaInsets,
}))(Screen);

0 comments on commit b696cb2

Please sign in to comment.