Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • C covid19india-react
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 27
    • Issues 27
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 11
    • Merge requests 11
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • covid19india
  • covid19india-react
  • Issues
  • #308
Closed
Open
Issue created Mar 28, 2020 by Administrator@rootContributor

Refactor code for routing and navbar using a dictionary with pageName-viewName

Created by: kousiksatish

This is a technical issue related to code management.

Current snippets of code:

# In App.js
<Route exact path="/links" render={(props) => <Links {...props}/>} />
<Route exact path="/summary" render={(props) => <Summary {...props}/>} />
<Route exact path="/clusters" render={(props) => <Cluster {...props}/>} />

# In navbar.js
<Link
  to="/clusters"
  onClick={() => {
    setView("Clusters");
  }}
>
  <span {...navLinkProps('/clusters', 0.3)}>
    Clusters
  </span>
</Link>

<Link
  to="/links"
  onClick={() => {
    setView("Helpful Links");
  }}
>
  <span {...navLinkProps('/links', 0.4)}>
    Helpful Links
  </span>
</Link>

As discussed in earlier PR https://github.com/covid19india/covid19india-react/pull/291 , this can be written in following way which will be better:

  • Create a dictionary with ViewName, Pathname key value pair to be used across the project, including in App.js and Navbar.js . Loop through this dictionary in both places.
  • In Navbar js create a new component for these links and create them by looping through the above mentioned dictionary.

We can reduce redundancy of code this way and also make adding new Views/Links easier.

Assignee
Assign to
Time tracking