Кнопка внутри всплывающей подсказки из элементов React Native не работает - PullRequest
0 голосов
/ 28 января 2020
import React from 'react';
import {
  Button,
  View,
  AsyncStorage,
  StyleSheet,
  Dimensions
} from 'react-native';
import {MaterialHeaderButtons, Item} from '../../navigation/MyHeaderButtons'
import {Tooltip} from 'react-native-elements'
import NewsFeed from './NewsFeed'
import RecentResults from './RecentResults'

export default class HomeScreen extends React.Component {
  static navigationOptions = {
    headerTitle: 'Home',
    headerRight: (
      <Tooltip
        popover ={<Button title="Sign out" onPress={this._signOutAsync}/>}
        withOverlay = {false}
      >
        <MaterialHeaderButtons>
          <Item title="add" iconName="settings"/>
        </MaterialHeaderButtons>      
      </Tooltip>
    )
  };

  render() {
    return (
      <View style = {styles.MainContainer}>
        <Button title="Sign out" onPress={this._signOutAsync}/>
        <NewsFeed/>
        <View style = {styles.ResultsContainer}>
          <RecentResults/>
        </View>
      </View>
    );
  }

  _signOutAsync = async () => {
    await AsyncStorage.clear();
    this.setState({login: false})
    this.props.navigation.navigate('Auth');
  };
}

const styles = StyleSheet.create({
  MainContainer: {
    backgroundColor:'rgb(35,31,32)',
    height: Dimensions.get('window').height
  },
})

Я пытался включить функцию выхода из системы в подсказку на главном экране моего приложения. Однако функция onPress не вызывается, когда кнопка находится внутри подсказки. Отлично работает, когда на экране просто простой компонент. Любая помощь будет принята с благодарностью.

...