diff --git a/native/bottom-sheet/bottom-sheet.react.js b/native/bottom-sheet/bottom-sheet.react.js index d790cbcdd..0b7b3cebe 100644 --- a/native/bottom-sheet/bottom-sheet.react.js +++ b/native/bottom-sheet/bottom-sheet.react.js @@ -1,65 +1,75 @@ // @flow -import { BottomSheetModal } from '@gorhom/bottom-sheet'; +import GorhomBottomSheet from '@gorhom/bottom-sheet'; import invariant from 'invariant'; import * as React from 'react'; import BottomSheetBackdrop from './bottom-sheet-backdrop.react.js'; import BottomSheetHandle from './bottom-sheet-handle.react.js'; import { BottomSheetContext } from './bottom-sheet-provider.react.js'; import { useStyles } from '../themes/colors.js'; type Props = { +children: React.Node, +onClosed: () => mixed, }; function ForwardedBottomSheet( props: Props, - ref: React.Ref, + ref: React.Ref, ): React.Node { const { children, onClosed } = props; const styles = useStyles(unboundStyles); const bottomSheetContext = React.useContext(BottomSheetContext); invariant(bottomSheetContext, 'bottomSheetContext should be set'); const { contentHeight } = bottomSheetContext; const snapPoints = React.useMemo(() => [contentHeight], [contentHeight]); + const onChange = React.useCallback( + (index: number) => { + if (index === -1) { + onClosed(); + } + }, + [onClosed], + ); + return ( - {children} - + ); } const unboundStyles = { background: { backgroundColor: 'modalForeground', }, }; const BottomSheet: React.AbstractComponent< Props, - React.ElementRef, -> = React.forwardRef>( + React.ElementRef, +> = React.forwardRef>( ForwardedBottomSheet, ); BottomSheet.displayName = 'BottomSheet'; const MemoizedBottomSheet: typeof BottomSheet = React.memo< Props, - React.ElementRef, + React.ElementRef, >(BottomSheet); export default MemoizedBottomSheet; diff --git a/native/user-profile/user-profile-bottom-sheet.react.js b/native/user-profile/user-profile-bottom-sheet.react.js index 34870ae76..1ab171203 100644 --- a/native/user-profile/user-profile-bottom-sheet.react.js +++ b/native/user-profile/user-profile-bottom-sheet.react.js @@ -1,57 +1,49 @@ // @flow import * as React from 'react'; import type { UserInfo } from 'lib/types/user-types'; import UserProfile from './user-profile.react.js'; import BottomSheet from '../bottom-sheet/bottom-sheet.react.js'; import type { RootNavigationProp } from '../navigation/root-navigator.react.js'; import type { NavigationRoute } from '../navigation/route-names.js'; import { useSelector } from '../redux/redux-utils.js'; export type UserProfileBottomSheetParams = { +userID: string, }; type Props = { +navigation: RootNavigationProp<'UserProfileBottomSheet'>, +route: NavigationRoute<'UserProfileBottomSheet'>, }; function UserProfileBottomSheet(props: Props): React.Node { const { navigation, route: { params: { userID }, }, } = props; const { goBackOnce } = navigation; const userInfo: ?UserInfo = useSelector( state => state.userStore.userInfos[userID], ); const bottomSheetRef = React.useRef(); - React.useEffect(() => { - if (!bottomSheetRef.current) { - return; - } - - bottomSheetRef.current.present(); - }, []); - const onClosed = React.useCallback(() => { goBackOnce(); }, [goBackOnce]); return ( ); } export default UserProfileBottomSheet;