[Android] animationOut for animate hiding the Modal didn't work on RN 0.61.5
See original GitHub issue[Android] react-native-modal props animationOut didn’t work…
I want to asking my problem about the animationOut on my modal. When I want to hide / close the modal, its working. But the animationOut props not working. I dont know it is bug or my code was wrong…
I’m using: “react-native”: “0.61.5” and “react-native-modal”: “^11.5.6”
And this is my code:
import React from 'react';
import {View, Text, TouchableOpacity} from 'react-native';
import Modal from 'react-native-modal';
import {colors} from '../../../../../../utils';
const ModalChooseProduct = props => {
return (
<Modal
animationIn="slideInUp"
animationOut="slideOutLeft"
animationInTiming={1000}
animationOutTiming={1000}
onSwipeComplete={props.onSwipeComplete}
swipeDirection="down"
isVisible={props.isVisible}
onBackdropPress={props.onBackdropPress}
hideModalContentWhileAnimating={true}
backdropTransitionInTiming={0}
backdropTransitionOutTiming={0}
style={{margin: 0, height: 100, justifyContent: 'flex-end'}}>
<View
style={{
height: '70%',
backgroundColor: colors.modal.outline,
borderRadius: 10,
}}>
<View style={{height: 30}} />
<View
style={{
borderTopStartRadius: 10,
borderTopEndRadius: 10,
backgroundColor: 'white',
height: '100%',
padding: 20,
}}>
<Text
style={{
color: colors.text.default,
fontWeight: 'bold',
fontSize: 15,
}}>
Please Choose your product:
</Text>
<TouchableOpacity
style={{width: '50%', height: '10%', backgroundColor: 'green'}}
onPress={props.closeModal}>
<Text>Close modal</Text>
</TouchableOpacity>
</View>
</View>
</Modal>
);
};
export default ModalChooseProduct;
Then I export them and importing to my Main file.js,
const [isModalVisible, setIsModalVisible] = useState(false);
const ToggleModal = () => {
setIsModalVisible(!isModalVisible);
};
const ModalProduct = () => {
return (
<ModalChooseProduct
isVisible={isModalVisible}
onBackdropPress={ToggleModal}
closeModal={ToggleModal}
onSwipeComplete={ToggleModal}
/>
);
};
return (
<View style={styles.container}>
<AddVoucherHeader
title="Create Voucher"
onPress={() => props.navigation.goBack()}
/>
<View style={{flex: 1, backgroundColor: 'white'}}>
<View style={{height: 13.3}} />
<Text
style={{paddingLeft: 10, fontSize: 16, color: colors.text.default}}>
Choose Product
</Text>
<ModalProduct />
<TouchableOpacity
onPress={ToggleModal}
style={{
justifyContent: 'center',
alignSelf: 'center',
width: '90%',
height: '10%',
backgroundColor: '#78be63',
borderRadius: 10,
}}>
<View
{...}
But if i try using “react-native”: “0.62.2”, its work properly, both of animationIn and animationOut.
What should I do ? I hope you can help me and solving my problem without updating my RN to 0.62.2…
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
Top Results From Across the Web
React Native Modal doesn't show animations - Stack Overflow
My problem is that the animations don't work in the Modal. The "animationIn" prop doesn't show any change if I set the value...
Read more >react-native-community - Bountysource
My goal is to close the current modal and open another one immediately. I tried to get it working by using setTimeout but...
Read more >react-native-modal - npm
An enhanced, animated, customizable React Native modal. The goal of react-native-modal is expanding the original React Native <Modal> ...
Read more >React Native Modal Drawer
React Native Modal DrawerInstallation Install rn-bottom-drawer. ... React Native provides two complementary animation systems: Animated for granular and ...
Read more >React native modal animation popup example with overlay
This animation also covers the button toggle and background color animation. For hiding the modal we used scale to 0.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I solved my problem… You can’t put the Modal container into the function… you CAN’T do this:
Because it will re-render your Modal Component. So the animationOut didn’t work… So, the solution is you should put
<ModalChooseProduct />
outside the function, and put it directly to the main jsx… And theres no need createconst ModulProduct = () => {}
again 😄Your welcome, glad to hear that @chaiiplss