Skip to content
Advertisement

How to have an array of objects based routing in react?

I am learning React. But I am familiar with Vue. In Vue with the Vue Router, we can have an array of objects based routing like,

JavaScript

What I tried so far is as below :

Login.jsx

JavaScript

Dashboard.jsx

JavaScript

App.js

JavaScript

But in the above approach, I am always getting redirected to “/login”. Is there anyways to fix this? Thanks in advance

Advertisement

Answer

Maybe this React-View-Router package help you. Instead of react-router-dom, try this package, and you can follow vue-router like syntax

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement