Giter Site home page Giter Site logo

Comments (2)

marklawlor avatar marklawlor commented on September 21, 2024

To clarify how Expo Router works - all routes are accessible from any page if you link to it. Likewise, all routes are deep-linkable. If you have a link to a route, it will work, no matter where you are.

Groups have 1 purpose, to select what _layout (and consequently what navigator) is rendered.

If you want a /users/[id] route that keeps within the same navigator that you are currently in , then your files structure should be

(home)/
├─ _layout.tsx
├─ index.tsx
├─ users/
│  ├─ index.tsx
(profile)/
├─ _layout.tsx
├─ profile.tsx
├─ users/
│  ├─ index.tsx

Where both users/index.tsx files reexport the same UsersPage component. This is similar to React Navigation where you would need to have two <Screen /> components that have the same component.

Shared groups are for when you have routes that have their own layouts, but could belong to multiple groups. We can't do what we did before (create multiple users/index.tsx files) because they are still under their parents _layout. The shared groups syntax allows you to express this.

The other purpose are pages with unique layouts

(home)/
├─ _layout.tsx
├─ index.tsx
├─ users/
│  ├─ index.tsx
(profile)/
├─ _layout.tsx
├─ profile.tsx
├─ users/
│  ├─ index.tsx
(profile,home)/
├─ _layout.tsx
├─ settings.tsx

Say we have have navigated from / to /settings. The Settings page has a Href to /users/1, but which route do we navigate to? Shared groups retains the state of which group you were in so it will navigate you to the correct /users/1

from expo.

the-devbear avatar the-devbear commented on September 21, 2024

Thank you a lot for taking the time and writing this detailed answer. It makes much more sense now for me.
Thanks again, and have a nice day!

from expo.

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.