Skip to content

Commit 8207456

Browse files
authored
Incubator.Dialog - Fixed content component being created on every render. (#3231)
* fixed DialogContent component being created on every render and casuing mounts and unmounts * rename variable
1 parent 439bfc5 commit 8207456

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/incubator/Dialog/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ const Dialog = (props: DialogProps, ref: ForwardedRef<DialogImperativeMethods>)
127127
// eslint-disable-next-line react-hooks/exhaustive-deps
128128
}, []);
129129

130-
const {DialogContent, containerProps, containerStyle} = useDialogContent({
130+
const {renderDialogContent, containerProps, containerStyle} = useDialogContent({
131131
showCloseButton,
132132
close,
133133
closeButtonProps,
@@ -215,7 +215,7 @@ const Dialog = (props: DialogProps, ref: ForwardedRef<DialogImperativeMethods>)
215215
<GestureDetector gesture={panGesture}>
216216
{/* @ts-expect-error should be fixed in version 3.5 (https://github.com/software-mansion/react-native-reanimated/pull/4881) */}
217217
<View {...containerProps} reanimated style={style} onLayout={onLayout} ref={setRef} testID={testID}>
218-
<DialogContent/>
218+
{renderDialogContent()}
219219
</View>
220220
</GestureDetector>
221221
);

src/incubator/Dialog/useDialogContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const useDialogContent = (props: InternalDialogCloseButtonProps) => {
4949
return showCloseButton ? [propsContainerStyle, styles.transparent] : propsContainerStyle;
5050
}, [showCloseButton, propsContainerStyle]);
5151

52-
const DialogContent = () => {
52+
const renderDialogContent = () => {
5353
const DialogContent = (
5454
<>
5555
{headerProps && <DialogHeader {...headerProps}/>}
@@ -69,7 +69,7 @@ const useDialogContent = (props: InternalDialogCloseButtonProps) => {
6969
}
7070
};
7171

72-
return {DialogContent, containerStyle, containerProps};
72+
return {renderDialogContent, containerStyle, containerProps};
7373
};
7474

7575
export default useDialogContent;

0 commit comments

Comments
 (0)