0.0.6 • Published 6 years ago

react-native-modal-alert v0.0.6

Weekly downloads
11
License
MIT
Repository
github
Last release
6 years ago

react-native-modal-alert

A react-native custom alert component

Install

yarn add react-native-modal-alert

or

npm install -S react-native-modal-alert

Usage

import React from 'react';
import { View, Text, TouchableOpacity } from 'react-native';
import ModalAlert from 'react-native-modal-alert';

export default class App extends React.PureComponent {
    constructor(props) {
        super(props);

        this.state = {
            isShow: false
        };
    }

    show = () => {
        this.setState({ isShow: true });
    };

    hide = () => {
        this.setState({ isShow: false });
    };

    onShow = () => {
        console.log('render alert');
    };

    render() {
        return (
            <View>
                <TouchableOpacity
                        onPress={this.show}
                        style={{
                            width: 300,
                            height: 200,
                            backgroundColor: '#fff',
                            borderRadius: 4
                        }}
                    >
                        <Text>Toggle</Text>
                </TouchableOpacity>
                <ModalAlert
                    visible={this.state.isShow}
                    onShow={this.onShow}
                    onClose={this.hide}
                >
                    <View><Text>modal content</Text></View>
                </ModalAlert>
            </View>
        );
    }
}
0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago