Получить реквизит из дома в TabNavigator, реагировать родной и реагировать навигации - PullRequest
0 голосов
/ 04 апреля 2020

Мне нужна ваша помощь, я создаю приложение с настраиваемой вкладкой, которую я делаю из учебника, но мне нужно передать некоторые параметры с главной страницы на панель вкладок, а также некоторые параметры на главную страницу, React Native, React Navigation

Мой основной файл ...

import React, { Component } from 'react';
import { View, Text, StyleSheet } from 'react-native';
import MyCustomTab from "../navigation/index"

export default class basetabs extends Component {
    constructor(props) {
        super(props);
        this.state = {
            nronotifications: null,
            nromessg: null
        };
    }

    componentDidMount = () => {
        ...
        ...
        //Here I update States..
        this.setState({
            nronotifications: XXXXX,
            nromessg: XXXX
        })
    }

    render() {
        return (
            <View style={styles.container}>
                <MyCustomTab notif={this.state.nronotifications} msg={this.state.nromessg} propstohome={'update'} />
            </View>
        );
    }
}
const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: "#eef",
    flexDirection: "column"
  },
  childContainer: {
    justifyContent: "center",
    alignItems: "center"
  },
  header: {
    backgroundColor: "cyan",
    width: "100%"
  }
});

MyCustomTab is ..:

//Here I need to retrieve the props data from the main

// let notif = ???????
// let msg = ???????
// let propstohome = ???????

const TabNavigator = createMaterialTopTabNavigator(
    {
        Home: {
            screen: Home  // here i need pass the props "propstohome"
        },
        Notif: {
            screen: Notif
        },
        Msg: {
            screen: Msg
        },
        Other3: {
            screen: Other3
        },
        Other4: {
            screen: Other4
        },
    },
    {
        tabBarComponent: MyTab,
        tabBarPosition: 'bottom',
        animationEnabled: true,
        tabBarOptions: {
            showIcon: true,
            activeTintColor: "#1BA1F3",
            inactiveTintColor: "#000",
            totalchats: notif,  //Here I need to put these values, only I do not know how to receive them
            totalnotif: msg   //Here I need to put these values, only I do not know how to receive them
        },
        initialRouteName: "Home"
    }
);
//createAppContainer(TabNavigator)
const Navigation = createAppContainer(TabNavigator);

export default Navigation;

для подведения итогов ... тогда мне нужно сделать 2 вещи

  1. , чтобы иметь возможность передавать параметры с главной страницы на вкладку навигации, чтобы иметь возможность показывать их рядом со значками

  2. для быть в состоянии передать параметр с главной страницы в навигацию и передать этот параметр, чтобы обновить sh домашнюю страницу

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...