n8udd
n8udd

Reputation: 731

Back button not functioning correctly after navigating to new route

I'm using Expo file based navigation in React Native and have the below file structure (with the names of the screens in the array).

The create modal is accessable from most authenticated (authed) routes.

When creating a new post (onSubmit) it completes the API POST and they should be directed to the myposts/[post] route.

They are being directed to a [post] route, but it appears to be posts/[post] rather than myposts/[post].

The show route ([post]) doesn't include a back button.

When I manually add it with navigation.setOptions, the back() function is taking me to posts/[post] rather than myposts/[post].

- /app
    - _layout.tsx                     ["(app)"]
    - /(app)
        - _layout.tsx                 <Slot />
        - /(authed)
            - _layout.tsx             ["(tabs), "settings", "create", "user/[user_id]"]
            - *create.tsx
            - settings.tsx
            - /(tabs)
                - _layout.tsx         ["(posts)", "home", "myposts"]
                - home.tsx
                - /posts
                    - _layout.tsx     ["index", "[post]", "filter", "sort"]
                    - index.tsx
                    - [post].tsx
                    - *filter.tsx
                    - *sort.tsx
                - myposts
                    - _layout.tsx     ["index", "filter", "sort", "[post]", "[post]/updates/create"]
                    - index.tsx
                    - [post].tsx
                    - /[post]/updates
                        - *create.tsx
                    - *filter.tsx
            - /user
                - *[user_id].tsx
                    
        - /public
            - _layout.tsx             ["posts", "(auth)", "info"]
            - info.tsx
            - /(auth)
                - _layout.tsx         ["login", "register", "forgot"]
                - forgot.tsx
                - login.tsx
                - register.tsx
            - /posts
                - _layout.tsx         ["index", "[post]"]
                - [post].tsx
                - index.tsx- /app
    - _layout.tsx                     ["(app)"]
    - /(app)
        - _layout.tsx                 <Slot />
        - /(authed)
            - _layout.tsx             ["(tabs), "settings", "create", "user/[user_id]"]
            - *create.tsx
            - settings.tsx
            - /(tabs)
                - _layout.tsx         ["(posts)", "home", "myposts"]
                - home.tsx
                - /posts
                    - _layout.tsx     ["index", "[post]", "filter", "sort"]
                    - index.tsx
                    - [post].tsx
                    - *filter.tsx
                    - *sort.tsx
                - myposts
                    - _layout.tsx     ["index", "filter", "sort", "[post]", "[post]/updates/create"]
                    - index.tsx
                    - [post].tsx
                    - /[post]/updates
                        - *create.tsx
                    - *filter.tsx
            - /user
                - *[user_id].tsx
                    
        - /public
            - _layout.tsx             ["posts", "(auth)", "info"]
            - info.tsx
            - /(auth)
                - _layout.tsx         ["login", "register", "forgot"]
                - forgot.tsx
                - login.tsx
                - register.tsx
            - /posts
                - _layout.tsx         ["index", "[post]"]
                - [post].tsx
                - index.tsx

Upvotes: 0

Views: 76

Answers (0)

Related Questions