Skip to content

[Bug]: Context prop in Outlet is not working with index routes. #8492

@umarjavedse

Description

@umarjavedse

What version of React Router are you using?

6.1.1

Steps to Reproduce

Setup project using below nested routes.

useRoutes([
    {
        path: '/',
        element: <Layout />,
        children: [
            {
                path: 'user',
                children: [
                    { index: true, element: <User /> },
                    { path: 'add', element: <AddUser /> },
                ],
            },
        ],
    },
])

and then use <Outlet context={data} /> in <Layout/>

Expected Behavior

Fetch data using useOutletContext hook.

Actual Behavior

Getting undefined with useOutletContext hook.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions