Best way to create sidebar navigation with React Router

What is the best way to handle sidebar based role navigation with React Router? Now I'm repeating myself with two side panels. I was thinking about creating a map to build, but didn't know if React Router has some functionality to create links based on the Role condition? If not, I check if there is a better approach than something like this below?

Currently I am just hard-linking the sidebar links instead of dynamically creating.

``,

const routes = _.map(props.links, (link) => {
    if(someRoleOnUser in link.roles) {
        return (<div><Link .... /></div>);
    } 
})

      

``,

+3


source to share





All Articles