Reputation: 1025
I'm using react-native-modalbox.
I want to open the ScreenB from the ScreenA.
and I want to close ScreenA after ScreenB open.
Anyone know how to solve it?
import Modal from 'react-native-modalbox';
import ScreenB from './ScreenB';
class ScreenA extends React.Component {
render() {
return (
<View>
<Modal
ref={"modal1"}
swipeToClose={true}
coverScreen={true}
><ScreenB></ScreenB>
</Modal>
<View>
<TouchableOpacity
onPress={() => this.refs.modal1.open()}>
<Text>Click me</Text>
</TouchableOpacity>
</View>
</View>
);
}
}
Upvotes: 0
Views: 811
Reputation: 51
/*********/
$<Modal transparent={true} visible={ this.props.loading }
onRequestClose={() => {this._setModalVisible(false)}}>
{loading}
</Modal>
_setModalVisible(visible) {
this.setState({loading: visible})
}$
/***********/
Upvotes: 1
Reputation: 4889
You looks using the modal way to show new page. It is different with replacing to a new page. Normally, modal is using to show a temporary page.
If you want to change the page from a to b and closing a, it will be better to use ReactNavigator or React Native Router. Then, find replace options with modal animation.
Upvotes: 0