123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- ---
- id: root
- title: Root
- sidebar_label: Root
- ---
-
- import Tabs from '@theme/Tabs';
- import TabItem from '@theme/TabItem';
-
- ## `setRoot()`
- Used to set the UI of the application. Read more about the root hierarchy level in the [docs section](../docs/root).
-
- #### Parameters
- | Name | Required | Type | Description |
- | ------ | -------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
- | layout | Yes | [Layout](layout-layout.mdx) | Any type of layout. [BottomTabs](layout-BottomTabs.mdx), [Stack](layout-stack.mdx), [SideMenu](layout-sideMenu.mdx), [Component](layout-component.mdx) |
-
- #### Example
-
- <Tabs
- defaultValue='stack'
- values={[
- { label: 'With Stack layout', value: 'stack' },
- { label: 'With BottomTabs layout', value: 'bottomTabs' }
- ]
- }>
-
- <TabItem value='stack'>
-
- ```js
- Navigation.setRoot({
- root: {
- stack: {
- children: [{
- component: {
- name: 'example.FirstTabScreen',
- passProps: {
- text: 'This is tab 1'
- }
- }
- }],
- options: {
- bottomTab: {
- text: 'Tab 1',
- icon: require('../images/one.png'),
- testID: 'FIRST_TAB_BAR_BUTTON'
- }
- }
- }
- }
- });
- ```
-
- </TabItem>
-
- <TabItem value='bottomTabs'>
-
- ```js
- Navigation.setRoot({
- root: {
- bottomTabs: {
- children: [{
- stack: {
- children: [{
- component: {
- name: 'example.FirstTabScreen',
- passProps: {
- text: 'This is tab 1'
- }
- }
- }],
- options: {
- bottomTab: {
- text: 'Tab 1',
- icon: require('../images/one.png'),
- testID: 'FIRST_TAB_BAR_BUTTON'
- }
- }
- }
- },
- {
- component: {
- name: 'navigation.playground.TextScreen',
- passProps: {
- text: 'This is tab 2'
- },
- options: {
- bottomTab: {
- text: 'Tab 2',
- icon: require('../images/two.png'),
- testID: 'SECOND_TAB_BAR_BUTTON'
- }
- }
- }
- }]
- }
- }
- });
- ```
-
- </TabItem>
-
- </Tabs>
|