Skip to content

Commit c6e661e

Browse files
meishuuyayvery
authored andcommitted
convert footer component to render function
1 parent 9e46a09 commit c6e661e

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
160160
handleComponent,
161161
backdropComponent,
162162
backgroundComponent,
163-
footerComponent,
163+
renderFooter,
164164
children: Content,
165165

166166
// accessibility
@@ -1659,10 +1659,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
16591659
>
16601660
{typeof Content === 'function' ? <Content /> : Content}
16611661

1662-
{footerComponent && (
1663-
<BottomSheetFooterContainer
1664-
footerComponent={footerComponent}
1665-
/>
1662+
{renderFooter && (
1663+
<BottomSheetFooterContainer renderFooter={renderFooter} />
16661664
)}
16671665
</BottomSheetDraggableView>
16681666
</Animated.View>

src/components/bottomSheet/types.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,11 +299,11 @@ export interface BottomSheetProps
299299
*/
300300
backgroundComponent?: React.FC<BottomSheetBackgroundProps> | null;
301301
/**
302-
* Component to be placed as a footer.
302+
* Function to render as the footer.
303303
* @see {BottomSheetFooterProps}
304-
* @type React.FC\<BottomSheetFooterProps\>
304+
* @type (props: BottomSheetFooterProps) => React.ReactElement | null;
305305
*/
306-
footerComponent?: React.FC<BottomSheetFooterProps>;
306+
renderFooter?: (props: BottomSheetFooterProps) => React.ReactElement | null;
307307
/**
308308
* A scrollable node or normal view.
309309
* @type (() => React.ReactElement) | React.ReactNode[] | React.ReactNode

src/components/bottomSheetFooterContainer/BottomSheetFooterContainer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React, { memo } from 'react';
1+
import { memo } from 'react';
22
import { useDerivedValue } from 'react-native-reanimated';
33
import { useBottomSheetInternal } from '../../hooks';
44
import { KEYBOARD_STATE } from '../../constants';
55
import type { BottomSheetFooterContainerProps } from './types';
66

77
const BottomSheetFooterContainerComponent = ({
8-
footerComponent: FooterComponent,
8+
renderFooter,
99
}: BottomSheetFooterContainerProps) => {
1010
//#region hooks
1111
const {
@@ -46,7 +46,7 @@ const BottomSheetFooterContainerComponent = ({
4646
]);
4747
//#endregion
4848

49-
return <FooterComponent animatedFooterPosition={animatedFooterPosition} />;
49+
return renderFooter({ animatedFooterPosition });
5050
};
5151

5252
const BottomSheetFooterContainer = memo(BottomSheetFooterContainerComponent);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import type { BottomSheetProps } from '../bottomSheet';
22

33
export interface BottomSheetFooterContainerProps
4-
extends Required<Pick<BottomSheetProps, 'footerComponent'>> {}
4+
extends Required<Pick<BottomSheetProps, 'renderFooter'>> {}

0 commit comments

Comments
 (0)