/** * The examples provided by Facebook are for non-commercial testing and * evaluation purposes only. * * Facebook reserves all rights not expressly granted. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL * FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * @flow */ 'use strict'; var React = require('react-native'); var { StyleSheet, TabBarIOS, Text, View, } = React; var TabBarExample = React.createClass({ statics: { title: '', description: 'Tab-based navigation.', }, displayName: 'TabBarExample', getInitialState: function() { return { selectedTab: 'redTab', notifCount: 0, presses: 0, }; }, _renderContent: function(color: string, pageText: string, num?: number) { return ( {pageText} {num} re-renders of the {pageText} ); }, render: function() { return ( { this.setState({ selectedTab: 'blueTab', }); }}> {this._renderContent('#414A8C', 'Blue Tab')} 0 ? this.state.notifCount : undefined} selected={this.state.selectedTab === 'redTab'} onPress={() => { this.setState({ selectedTab: 'redTab', notifCount: this.state.notifCount + 1, }); }}> {this._renderContent('#783E33', 'Red Tab', this.state.notifCount)} { this.setState({ selectedTab: 'greenTab', presses: this.state.presses + 1 }); }}> {this._renderContent('#21551C', 'Green Tab', this.state.presses)} ); }, }); var styles = StyleSheet.create({ tabContent: { flex: 1, alignItems: 'center', }, tabText: { color: 'white', margin: 50, }, }); module.exports = TabBarExample;