erikras / erikras/react-redux-universal-hot-example

How to create dynamic routes on the basis of json data in universal boilerplate

Open
#984 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
12.1k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

Hello erikras

I am quite a beginner in terms of following the react redux boilerplate.
hats off for your amazing efforts..

I really need suggestions on handling dynamic routing

Lets take a simple scenario..
In **routes.js**

``
``
``
``

**data.js**

```
export const data = [
{id: 1, property: 'Dashboard', link: '/'},
{id: 2, property: 'Login', link: '/login'},
{id: 3, property: 'About Us', link: '/About'},
];
```

now, let say on the basis of user role, the properties in json data will change

let say _new property:_ is

{id: 4, property: 'test page', link: '/test'}

The problem lies . when react will render the components, how it would know the route link .. as it is not defined in the routes.js

I know it seems stupid of me to ask such thing, but i am not getting the right way to implement it

can anyone please suggest some proper way to deal with this case, as i think this scenario is very common in CMS Development, we need a sidebar made of specific menu content as per the user role .

Let say we are building a reservation system , there can be different user roles like admin, maintenance mode, assistant role
.

So different role will have different properties, accordingly we need to generate the menu on the basis it, as the properties will definitely differ as per user role.

I am getting insane, as i really want to implement it in a cleaner way within the erik's universal bolierplate .

Help Please

Thanks!!

PS: I am really stuck here., jst a basic scenario can be of great help to me. :).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.