Skip to content

Change route paths from repetitive strings to constants in line with DRY principle which will limit issues regarding paths. #178

@EmmanuelObi

Description

@EmmanuelObi

Example

Current Code:

  <Route path="/products" element={<AddNewProductPage1 />} />
    <Route path="/login" element={<Login />} />
    <Route path="/create-account" element={<CreateAccount />} />
    <Route path="/email-verification" element={<EmailVerify />} />
    <Route path="/phone-verification" element={<PhoneNumberVerification/>} />

Suggested change?

import {PRODUCTS, LOGIN, CREATEACCOUNT, EMAILVERIFICATION} from "../../routeConstants.js"

      <Route path={`/${PRODUCTS}`} element={<AddNewProductPage1 />} />
      <Route path={`/${LOGIN}`} element={<Login />} />
      <Route path={`/${CREATEACCOUNT}`} element={<CreateAccount />} />
      <Route path={`/${EMAILVERIFICATION}`} element={<EmailVerify />} />

All route constants can be declared in one file, and exported to be used anywhere in the app. Every contributor can access that file as a point of contact instead of wondering what the spelling of route paths are.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions