Requirements
react-native-reanimated
- Installation
npm install react-native-remodal
- Wrap your root component with the
ReModalProvider
<ReModalProvider>...</ReModalProvider>
- Use it!
<ReModal isVisible={open} onCancel={() => setOpen(false)}>
...
</ReModal>
children
: React.ReactElement;isVisible
: boolean;onCancel
?: () => void;autoCloseWhenOpeningNextDialog
?: boolean;modalAnimationFunction
?: (gestureState: Animated.Adaptable, opacity: Animated.Adaptable, modalLayout?: { width: Animated.Adaptable; height: Animated.Adaptable; })=> any;onModalShow
?: () => void;onModalHide
?: () => void;containerStyle
?: ViewStyle;onShowConfig
?: AnimationConfigs;onHideConfig
?: AnimationConfigs;
duration
: number;easing
: Animated.EasingFunction;
import React, { useState } from 'react';
import { Button, Dimensions, Text, View } from 'react-native';
import { ReModal } from 'react-native-remodal';
export default function ModalTest(props) {
const [open1, setOpen1] = useState(false);
const [open2, setOpen2] = useState(false);
return (
<View style={{ alignItems: 'center', justifyContent: 'center', flex: 1 }}>
<ReModal isVisible={open1} onCancel={() => setOpen1(false)}>
<View style={{ width: Dimensions.get('window').width * 0.8, backgroundColor: '#fff', padding: 32 }}>
<Text>This is a test!</Text>
<Button onPress={() => setOpen2(true)} title="Show Modal #2" />
</View>
</ReModal>
<ReModal isVisible={open2} onCancel={() => setOpen2(false)}>
<View style={{ width: Dimensions.get('window').width * 0.8, backgroundColor: '#fff', padding: 32 }}>
<Text>This is another modal!</Text>
</View>
</ReModal>
<Button onPress={() => setOpen1(true)} title="Show Modal #1" />
<Button onPress={() => setOpen2(true)} title="Show Modal #2" />
</View>
);
}