Typescript - Left side of comma operator is unused and has no side effects - How to use constants in place of strings in hookrouter's route?

Viewed 21901
import React from "react";
import Users from "./components/Users";
import Contact from "./components/Contact";
import About from "./components/About";
const routes = {
  "/": () => <Users />,
  "/about": () => <About />,
  "/contact": () => <Contact />
};
export default routes;

May I know how to use constants instead of strings in the routes as follows please?

const root = "/";

const routes = {
  `${root}`: () => <Users />,
};

When I tried the code above, I got the following error:

Left side of comma operator is unused and has no side effects
1 Answers
Related