react-route-webpack- Unhandled Rejection (TypeError) callback is not a function. (In 'callback(null, __webpack_require__(/*! ./pages/NotFound.js */ "./src/pages/NotFound.js").default)', 'callback' is undefined))

修改Route.js

问题:×
Unhandled Rejection (TypeError): callback is not a function. (In ‘callback(null, webpack_require(/! ./pages/NotFound.js / “./src/pages/NotFound.js”).default)’, ‘callback’ is undefined)
解决:
(1)报错部分

1
2
3
4
5
6
7
8
9
10
const Routes = () => (
<Router history = {history} createElement = {createElement}>
<Route path="/" component={App}>
<IndexRoute getComponent={getHomePage}/>
<Route path="home" getComponent={getHomePage}/>
<Route path="about" getComponent={getAboutPage}/>
<Route path="*" getComponent={getNotFoundPage()}/> //报错
</Route>
</Router>
)

(2)修改后

1
2
3
4
5
6
7
8
9
10
const Routes = () => (
<Router history = {history} createElement = {createElement}>
<Route path="/" component={App}>
<IndexRoute getComponent={getHomePage}/>
<Route path="home" getComponent={getHomePage}/>
<Route path="about" getComponent={getAboutPage}/>
<Route path="*" getComponent={getNotFoundPage}/>
</Route>
</Router>
)