I want to use react-router-rom and can we still use react-router-dom V5 in today's date? since it support custom route components, while react-router-dom V6+ has strict rules to use Route & Routes. Can anybody help me out, what suits good?
3 Replies
...you would need to get a lot of benefit out of a deprecated feature to make it worth using (and potentially forking to backport security fixes after the core maintainers stop doing that) by deliberately using an outdated dependency. There's some nuance but the short answer is "don't do that", here or just in general.
FWIW, yeah, sure, you can use old and outdated libraries, but be prepared for them to not work with newer codebases as well as newer versions will. I've closed your question as a duplicate of this post, which asks about and covers how to create and use route guards the old RRDv4/5 way, as well as with the current RRDv6/7 way. Sure, migrating from v4/5 to v6/7 is/was a heavy mental shift, but to be quite honest it will be hugely beneficial for you to migrate to v6/7 as routing and navigating really did become a bit simpler.
React Router V6 has a backwards compatibility package. Perhaps that's a middleground worth exploring?