[Bug]: Wrong proptype for from in Redirect component

2
closed
Axnyff
Axnyff
Posted 1 month ago

[Bug]: Wrong proptype for from in Redirect component #8136

What version of React Router are you using?

5.3.0

Steps to Reproduce

https://codesandbox.io/s/react-router-v5-forked-pqsli if we use an array of string as the from prop we have a warning that the propTypes is wrong. However, the code looks like it's working fine.

I've checked inside the code how computedMatch is calculated and it looks like an array won't cause any problems to it.

Expected Behavior

There should'nt be any warning if we give the component an array of string.

Actual Behavior

There is a warning if we supply an array of string.

Thanks for your help, I can write a fix for this if we agree this is an issue

timdorr
timdorr
Created 1 month ago

While it's supported by the underlying matching library (path-to-regexp), we don't support this in our propTypes. It hasn't worked in prior versions and won't work in v6. It's a "secret" feature that you shouldn't rely on. Instead, just use multiple Redirects.

Axnyff
Axnyff
Created 1 month ago

Ok, thanks for the answer!

have a great day