Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions docs/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,70 @@ permalink: docs/modal.html
next: navigatorios
previous: maskedviewios
---

Minimal modal example:

```
import React, { Component } from 'react';
import { Text, View, Button, Modal, StyleSheet } from 'react-native';

export default class MyComponent extends Component {
state = {
modalVisible: false,
};

openModal() {
this.setState({modalVisible:true});
}

closeModal() {
this.setState({modalVisible:false});
}

render() {
return (
<View style={styles.container}>
<Modal
visible={this.state.modalVisible}
animationType={'slide'}
onRequestClose={() => this.closeModal()}
>
<View style={styles.modalContainer}>
<View style={styles.innerContainer}>
<Text>This is content inside of modal component</Text>
<Button
onPress={() => this.closeModal()}
title="Close modal"
>
</Button>
</View>
</View>
</Modal>
<Button
onPress={() => this.openModal()}
title="Open modal"
/>
</View>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
},
modalContainer: {
flex: 1,
justifyContent: 'center',
backgroundColor: 'grey',
},
innerContainer: {
alignItems: 'center',
},
});
```

### Props

- [`visible`](docs/modal.html#visible)
Expand Down