Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

(React Typescript) 'Component' refers to a value, but is being used as a type here. Did you mean 'typeof Component'?

I want to make routes array and apply it on useRoutes from react-router@6. Currently I am using typescript and vite. But, i got error when try to assign my component to ‘element’ key.

type HelloWorld = /unresolved/ any
‘HelloWorld’ refers to a value, but is being used as a type here. Did you mean ‘typeof
HelloWorld’?ts(2749)
Parsing error: ‘>’ expected.eslint

import { useRoutes, RouteObject } from "react-router-dom"

import { HelloWorld } from "@/HelloWorld"

export function Router (): ReturnType<typeof useRoutes> {
  const routes: RouteObject[] = [
    {
      path: "hello-world",
      element: <HelloWorld />
    }
  ]

  return useRoutes(routes)
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Please make sure that your file has the .tsx file extension and is not just a .ts file.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading