我想使用浏览器的路由和react-router-dom的路由来路由应用程序中的react组件,但是会出错
错误:
Line 44: Parsing error: Unterminated JSX contents
42 | <Route path='/edit' component={EditExpensePage} />
43 | </div>
> 44 | </BrowserRouter>
| ^
45 | );
__文件:__
import React from 'react';
import ReactDOM from 'react-dom';
import {BrowserRouter,Route} from 'react-router-dom';
const HelpPage =()=>{
return(
<div>
This is from HelpPage
</div>
);
}
const EditExpensePage =() =>{
return(
<div>
This is from EditExpensePage
<div>
);
}
const routes=(
<BrowserRouter>
<div>
<Route path='/' component={HelpPage} exact={true}/>
<Route path='/edit' component={EditExpensePage} />
</div>
</BrowserRouter>
);
ReactDOM.render(routes, document.getElementById('root'));
我尝试过将其制作为无状态组件(路由)并将其呈现为React组件,但是它没有用,并且仍然出现未确定的jsx内容错误
答案 0 :(得分:0)
这是答案:
const EditExpensePage =() =>{
return(
<div>
This is from EditExpensePage
</div>
);