1.0.5 • Published 7 years ago

react-native-hideable-view-49 v1.0.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

React Native Hideable View


A component for React Native that can show/hide its child components.

Installation

npm install --save react-native-hideable-view

Usage

import HideableView from 'react-native-hideable-view';

<HideableView visible={boolean}>
  <YourView />
</HideableView>

Props

PropTypeDefaultDescription
visibleboolfalseShow/Hide the View
durationint500Animation time (ms)
removeWhenHiddenboolfalseUnmount component when hidden
noAnimationboolfalseIf true, no animation

Example

import React, { Component } from 'react';
import { View, Text, TouchableOpacity  } from 'react-native';

import HideableView from 'react-native-hideable-view';

class Example extends Component {
    constructor(props) {
        super(props);
        this.state = {
            visible: false
        };
        this.toggle = this.toggle.bind(this);
    }

    toggle() {
        this.setState({
            visible: !this.state.visible
        });
    }

    render() {
        return (
            <View style={styles.container}>
                <Text style={styles.title}>
                    I am always here.
                </Text>
                <HideableView visible={this.state.visible}>
                    <Text>
                      I appear and disappear at your behest.
                    </Text>
                </HideableView>
                <TouchableOpacity onPress={this.toggle}>
                    <Text>{this.state.visible ? 'Hide' : 'Show'}</Text>
                </TouchableOpacity>
            </View>
        );
    }
}