我使用wrapper
启动了我的项目。
我已将index.html div id设置为getElementById('wrapper')
,并在index.js处设置IndexRoute
。
我没有得到任何错误。我只得到一个警告,提到ReactDOM.render(
<BrowserRouter store={store}>
<Route routes={routes} onUpdate={logPageView} />
</BrowserRouter>,
document.getElementById('wrapper')
);
说:类型无效 - 期望一个字符串(用于内置组件)或一个类/函数(用于复合组件)但得到:undefined
如何让我的页面显示?
回购在这里:
https://github.com/yarnball/ReactAuthToken
export default (
<Route path="/" component={App}>
<IndexRoute component={HomePage} />
<Route path="register" component={Register} />
<Route path="login" component={Login} />
<Route path="logout" component={Logout} />
<Route path="forgot-password" component={ForgotPassword} />
<Route path="reset-password/:resetToken" component={ResetPassword} />
<Route path="dashboard">
<IndexRoute component={RequireAuth(Dashboard)} />
</Route>
<Route path="*" component={NotFoundPage} />
</Route>
);
lstart
答案 0 :(得分:1)
尝试以下更改
import { Provider } from 'react-redux';
import Routes from './routes';
...
ReactDOM.render(
<Routes store={store} />,
document.getElementById('wrapper')
);
import { BrowserRouter, Route } from 'react-router-dom';
...
export default (props) => (
<BrowserRouter>
<Provider store={props.store}>
<div>
<Route path="/" component={App} />
<Route path="register" component={Register} />
<Route path="login" component={Login} />
<Route path="logout" component={Logout} />
<Route path="forgot-password" component={ForgotPassword} />
<Route path="reset-password/:resetToken" component={ResetPassword} />
<Route path="*" component={NotFoundPage} />
</div>
</Provider>
</BrowserRouter>
);