Should I import an exported constant that has multiple components in an array?

Viewed 26

Let's say I have a constant in a file.

//routes.ts
export const routes = [
  {path: "/", component: component1 },
  {path: "/two", component: component2 }
]

If I then import this const in any react component, does it import all the components too? This wouldn't be a problem if I just use it for mapping the routes. But in some other components I need the array only for the path property. If I import the const in those components, will it add the component imports from routes.ts in those components as well? Should this be a performance issue?

0 Answers
Related