我只是在我的 React 应用程序中做一些基本的路由,我之前已经这样做了,所以我很困惑为什么它现在不起作用。
我得到的错误说: You should not use <Route> or withRouter() outside a <Router>
我确定这是超级基本的所以感谢你和我一起裸露!
import React from 'react'
import { Route } from 'react-router-dom'
import { Link } from 'react-router-dom'
import * as BooksAPI from './BooksAPI'
import BookList from './BookList'
import './App.css'
class BooksApp extends React.Component {
state = {
books: []
}
componentDidMount() {
this.getBooks()
}
getBooks = () => {
BooksAPI.getAll().then(data => {
this.setState({
books: data
})
})
}
render() {
return (
<div className="App">
<Route exact …Run Code Online (Sandbox Code Playgroud)