Giter Club home page Giter Club logo

Comments (6)

kanzitelli avatar kanzitelli commented on May 28, 2024 1

Hi @ssk-mps! Thank you!

And yes, you can achieve it with rn-navio as it's fully built on React Navigation. Once you built your layout with const navio = Navio.build(...), you can generate <navio.Root /> component which takes two arguments initialRouteName and navigationContainerProps. The latter will be passed directly to NavigationContainer. In your case, it's going to be something like <navio.Root navigationContainerProps={{linking: yourLinkings}} /> (as here, AppRoot == navio.Root).

from expo-starter.

ssk-mps avatar ssk-mps commented on May 28, 2024

That's awesome! Thanks for the pointer. It would be great to document this in the rn-navio readme file.

What is the best way to get the RootStackParamList that is generated by rn-navio? Here is the code that I have:

import { LinkingOptions } from '@react-navigation/native';
import * as Linking from 'expo-linking';

import { RootStackParamList } from '../types';

const linking: LinkingOptions<RootStackParamList> = {
  prefixes: [Linking.createURL('/')],
  config: { ... }
}

and I've explicitly defined the type of RootStackParamList as follows:

export type RootStackParamList = {
  Root: NavigatorScreenParams<RootTabParamList> | undefined;
  Modal: undefined;
  NotFound: undefined;
};

from expo-starter.

kanzitelli avatar kanzitelli commented on May 28, 2024

hey @ssk-mps! Glad it helped! And definitely, I am collecting some feedback and feature requests that will be implemented in the next releases.

Could you elaborate more on that and give broader example with use cases? That would be helpful as I don't fully get it.

from expo-starter.

ssk-mps avatar ssk-mps commented on May 28, 2024

Hi @kanzitelli The use-case is pretty much TypeScript type safety. When I declare const linking = {...}, then TS doesn't know what this object should be. But when I declare const linking: LinkingOptions<RootStackParamList> = { ... } then TS can catch the problems in the linking. This is why LinkingOptions type is exposed by @react-navigation/native. I hope it helps

from expo-starter.

kanzitelli avatar kanzitelli commented on May 28, 2024

@ssk-mps ah okay, got it! so currently rn-navio doesn't provide a type that describes the structure of the app, RootStackParamList in your case. maybe I'll come up with something in the future. I will add it into README as well, but now you will need to define it yourself as you do. the structure that navio builds might look like this:

const navio = Navio.build({
  screens: {
    Main,
    Settings,
    Example,
    Playground,
  },
  stacks: {
    MainStack: ['Main', 'Example'],
    ExampleModalStack: ['Example'],
  },
  tabs: {
    MainTab: {
      stack: 'MainStack',
    },
    PlaygroundTab: {
      stack: ['Playground'],
    },
    SettingsTab: {
      stack: ['Settings'],
    },
  },
  modals: {
    ExampleModal: 'ExampleModalStack',
  },
  root: 'Tabs', // 'Tabs' by default; takes also any stack name as a value
});

export type RootStackParamList = {
  // tabs
  Tabs: {
    MainTab: {
       Main: <props>,
       Example: <props>,
    },
    PlaygroundTab: {
      Playground: <props>,
    },
    SettingsTab: {
       Settings: <props>,
    },
  },
  
  // stacks, as you can .pushStack() as well
  ExampleStack: { 
    Example: <props>
  },
  
  // modals
  ExampleModal: {
    Example: <props>
  }
}

Hope it helps! And let me know how it works in your case :)

from expo-starter.

ssk-mps avatar ssk-mps commented on May 28, 2024

That works for me! Thanks @kanzitelli Please feel free to close this issue.

from expo-starter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.