Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add example to Modal documentation #17006

Closed
wants to merge 1 commit into from
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