question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow an array of strings in <Route path>

See original GitHub issue

This is a follow-up from #5393.

It would be nice if <Route path> could accept an array of strings instead of a single string. This would make it possible to render the same <Route> element at multiple different URLs as suggested here.

The reason #5393 was not merged is because there was a problem with the way the code worked with respect to relative routes. When this work is done, match.path should still be a string, not an array.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:44
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
kyleramirezcommented, Apr 29, 2018

What needs to be done to remove this prop-types warning?

In the meantime, I patch this in my own codebase by overriding the default prop types.

For those of you reading this, here is what I do:

import { Route } from "react-router-dom"
import PropTypes from "prop-types"

Route.propTypes = {
  computedMatch: PropTypes.object,
  path: PropTypes.oneOfType([PropTypes.array, PropTypes.string]),
  exact: PropTypes.bool,
  strict: PropTypes.bool,
  sensitive: PropTypes.bool,
  component: PropTypes.func,
  render: PropTypes.func,
  children: PropTypes.oneOfType([PropTypes.func, PropTypes.node]),
  location: PropTypes.object
}
5reactions
mjacksoncommented, Oct 15, 2018

Closed by #5889.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Allow an array of strings in <Route path> · Issue #5866 - GitHub
This is a follow-up from #5393. It would be nice if <Route path> could accept an array of strings instead of a single...
Read more >
How to pass array of strings in route? - angular - Stack Overflow
You can pass the array as a queryParams by JSON.stringify . And use JSON.parse to get the array in target page.
Read more >
Arrays in query params - Medium
Some APIs have a way to return partial objects in responses, that is, objects with a limited set of fields. Let's see how...
Read more >
Helpers - Laravel - The PHP Framework For Web Artisans
The Str::remove method removes the given value or array of values from the string: use Illuminate\Support\Str;. $string ...
Read more >
Parameter Serialization - Swagger
Serialization means translating data structures or object state into a format that can be transmitted and reconstructed later. OpenAPI 3.0 supports arrays and ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found