7
7
700Hp2021-11-06 16:32:33
JavaScript
700Hp, 2021-11-06 16:32:33

Attempted import error... Why doesn't import from react-router-dom work?

import React from 'react'
import {Redirect, Route, Routes} from "react-router-dom"
import App from "../pages/App"
import Book from "../pages/Book"
const AppRouter = () => {
    return (
        <div>
            <Routes>
                <Route path='/' exact={true} key={'/'} component={App}></Route>
                <Route path='/book' exact={true} key={'/'} component={Book}></Route>
                <Redirect to={'/'}></Redirect>
            </Routes>
        </div>
    )
}


In this code example, imports do not work.
Attempted import error: 'Redirect' is not exported from 'react-router-dom'.
It's the same with switch.

"react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-router": "^6.0.1",
    "react-router-dom": "^6.0.1",

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question