How to set initial tab in createBottomTabNavigator()

user938363

In the app with react navigation 3.11.0, there are 3 tabs:

return createBottomTabNavigator(
          {
            Event: {
              screen: EventStack,
              navigationOptions: {
                title: "Event",
              },
            },
            Group: {
              screen: GroupStack,
              navigationOptions: {
                title: "Group",
              },
            },
            Contact: {
              screen: ContactStack,
              navigationOptions: {
                title: "Contact",
              },
            },
          }, bottomTabNavOptions,
           {initialRouteName: Group}  //<<<== did not work
      );

I would like to set an initial tab on Group. Tried

{initialRouteName: Group}

and

{initialTabNavigator: Group}

Both of them did not work. What is the right way to set initial tab?

The bottomTabNavOptions is:

const bottomTabNavOptions =  {
  defaultNavigationOptions: ({ navigation }) => ({
    tabBarIcon: ({ focused, tintColor }) => {
      const { routeName } = navigation.state;
      console.log("route name", routeName);
      let iconName;
      if (routeName === 'Event') {
        iconName = `list-unordered`;
      } else if (routeName === 'Contact') {
        iconName = `person`;
      } else if (routeName === 'Group') {
        iconName = `organization`
      }

      return <Icon name={iconName} size={30} color={tintColor} type='octicon' />;
    },
  }),
  tabBarOptions: {
    activeTintColor: 'tomato',
    inactiveTintColor: 'gray',
  },
};
hong developer

The createBottomTabNavigator tab has two parameters. But you seem to be sending three parameters.

createBottomTabNavigator(RouteConfigs, BottomTabNavigatorConfig);

BottomTabNavigatorConfig:

  • initialRouteName: string
createBottomTabNavigator(
          {
            Event: {
              screen: EventStack,
              navigationOptions: {
                title: "Event",
              },
            },
            Group: {
              screen: GroupStack,
              navigationOptions: {
                title: "Group",
              },
            },
            Contact: {
              screen: ContactStack,
              navigationOptions: {
                title: "Contact",
              },
            },
          }, 
           {
            initialRouteName: 'Group', <= you use string
            bottomTabNavOptions,
           } 
      );

Este artigo é coletado da Internet.

Se houver alguma infração, entre em [email protected] Delete.

editar em
0

deixe-me dizer algumas palavras

0comentários
loginDepois de participar da revisão

Artigos relacionados

Reset createBottomTabNavigator to initial tab on navigation

react native createbottomtabnavigator hide tab bar label

How to set an active tab

createBottomTabNavigator пробел (значок автоматически скрывается) при отображении клавиатуры

How to give a Class name to an initial Tab Bar Controller?

How to set tab for zsh autocompletion?

Wagtail ModelAdmin > how to set initial data for an InlinePanel?

How to set initial state of rnn as parameter in tensorflow?

How to set initial values for NSUserDefault Keys?

how to set initial(default) value in dropdownButton?

How to set initial value of ForeignKey dynamically in CreateView?

How to set my database back to the initial values

How to set up initial data for different databases?

How to add createBottomTabNavigator to same screen with createStackNavigator

How to set active tab in Tab from Material UI programatically

How can I set a layout to a tab in QTabWidget?

How to set Title of Tab with MVVMCross 6.2?

How to set first tab after loading page?

aframe: how does look-controls set its initial values

how to set an initial value for an entity attribute in Jhipster JDL?

How do we set FSM Initial State in VHDL?

How to set style on an element after setting `all: initial;` on it?

How to set an initial/default value for the array used by <FieldArray/>?

how to set default initial value on nz-autocomplete

How to set initial condition to get the trajectory as a solution of the equation of the motion?

How to set an initial value for @NSManaged property PFObject Subclass?

How to set initial data (not test data) in Symfony with doctrine ORM

GNU Readline: how to set the initial content of the input string

Google Chart: how to set initial selection with listener for interactive

TOP lista

  1. 1

    R Shiny: use HTML em funções (como textInput, checkboxGroupInput)

  2. 2

    O Chromium e o Firefox exibem as cores de maneira diferente e não sei qual deles está fazendo certo

  3. 3

    Como assinar digitalmente um documento PDF com assinatura e texto visíveis usando Java

  4. 4

    R Folheto. Dados de pontos de grupo em células para resumir muitos pontos de dados

  5. 5

    Gerenciar recurso shake de Windows Aero com barra de título personalizado

  6. 6

    Como obter dados API adequados para o aplicativo angular?

  7. 7

    UITextView não está exibindo texto longo

  8. 8

    Por que meus intervalos de confiança de 95% da minha regressão multivariada estão sendo plotados como uma linha de loess?

  9. 9

    Acessando relatório de campanhas na AdMob usando a API do Adsense

  10. 10

    Usando o plug-in Platform.js do Google

  11. 11

    Como posso modificar esse algoritmo de linha de visada para aceitar raios que passam pelos cantos?

  12. 12

    Dependência circular de diálogo personalizado

  13. 13

    Coloque uma caixa de texto HTML em uma imagem em uma posição fixa para site para desktop e celular

  14. 14

    iOS: como adicionar sombra projetada e sombra de traço no UIView?

  15. 15

    Como usar a caixa de diálogo de seleção de nomes com VBA para enviar e-mail para mais de um destinatário?

  16. 16

    Tabela CSS: barra de rolagem para a primeira coluna e largura automática para a coluna restante

  17. 17

    How to create dynamic navigation menu select from database using Codeigniter?

  18. 18

    Converter valores de linha SQL em colunas

  19. 19

    ChartJS, várias linhas no rótulo do gráfico de barras

  20. 20

    用@StyleableRes注释的getStyledAttributes。禁止警告

  21. 21

    não é possível adicionar dependência para com.google.android.gms.tasks.OnSuccessListener

quentelabel

Arquivo