Home  >  Q&A  >  body text

Use colon and comma invite + react in createBrowserRouter

Hi, I've been searching but couldn't find any similar question. The server I'm using is running, but it's not working as expected from the tutorial I'm following.

I'm using the latest versions of vs code, xampp, composer, Laravel, nodejs and npm, so here's the code:

import {createBrowserRouter} from "react-router-dom";

//指定路由
const router = createBrowserRouter(routes: [])
export default router;

The colon before routes (routes:) has an underline in red and displays "expected ','". I'm following this video https://youtu.be/qJq9ZMB2Was, at about 23:02.

Thank you very much for your help, I am still learning and am a beginner in this field.

should not be underlined in red.

P粉165522886P粉165522886431 days ago472

reply all(1)I'll reply

  • P粉005105443

    P粉0051054432023-09-07 20:13:17

    The routes: you see in the video is not actually part of the code; it comes from an IDE extension that displays the developer's function parameter names. So just change it to:

    const router = createBrowserRouter([])
    

    reply
    0
  • Cancelreply