Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs]: V6 - Mixing up <Route /> with lists [<Route />, <Route />] within one <Routes /> looks working but isn't mentioned in the docs and covered in unit tests. #11503

Closed
chi11ed opened this issue Apr 26, 2024 · 1 comment
Labels

Comments

@chi11ed
Copy link

chi11ed commented Apr 26, 2024

Describe what's incorrect/missing in the documentation

Hi!

Just noticed that sometimes in the legacy projects entire batches of routes are stored as arrays.

So when migrating from v5 to v6 there can be unclear working situation when one can do something like this:

      <Routes>
        <Route path="/" element={<Layout />}>
          <Route index element={<Home />} />
          {[
            <Route
              path="about"
              element={
                <React.Suspense fallback={<>...</>}>
                  <About />
                </React.Suspense>
              }
            />,
            <Route
              path="dashboard/*"
              element={
                <React.Suspense fallback={<>...</>}>
                  <Dashboard />
                </React.Suspense>
              }
            />,
          ]}
          <Route path="*" element={<NoMatch />} />
        </Route>
      </Routes>

Despite there is error output regarding missing keys - it seems to be silently working, but

  1. It's not documented
  2. Unit tests contain only test for Fragment

Could you please add some for better clarity around arrays usages? Maybe worth to mention that those are expected to be flattened.

@chi11ed chi11ed added the docs label Apr 26, 2024
@chi11ed chi11ed changed the title [Docs]: V6 - Mixing up <Route /> with lists [<Route />, <Route />] within one <Switch /> looks working but isn't mentioned in the docs and covered in unit tests. [Docs]: V6 - Mixing up <Route /> with lists [<Route />, <Route />] within one <Routes /> looks working but isn't mentioned in the docs and covered in unit tests. Apr 26, 2024
@timdorr
Copy link
Member

timdorr commented Apr 26, 2024

This isn't a supported way of building route trees, so we're not going to document it. It may happen to work, but that's not intentional.

@timdorr timdorr closed this as not planned Won't fix, can't repro, duplicate, stale Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants