2017-03-07 49 views
0

我使用教程這裏找到:module.exports不工作ES6

https://github.com/reactjs/react-router-tutorial/blob/master/lessons/14-whats-next/modules/routes.js

然而,當複製:

module.exports = (
    <Route path="/" component={App}> 
    <IndexRoute component={Home}/> 
    <Route path="/repos" component={Repos}> 
     <Route path="/repos/:userName/:repoName" component={Repo}/> 
    </Route> 
    <Route path="/about" component={About}/> 
    </Route> 
) 

Webstorm是突出的支架和使用:

import React from 'react' 
import { Router, browserHistory } from 'react-router' 
import routes from './routes' 

但是路線拋出錯誤

Default export is not declared in imported module 

頁面只是空白,沒有反應代碼。爲什麼我不能像教程代碼中所示那樣導出模塊?

我的代碼的其餘部分是ES6

+0

顯示您的package.json – pmirnd

回答

2

rselvaganesh在技術上是正確的,但是在這種情況下,它應該是:

export default (
    <Route path="/" component={App}> 
    <IndexRoute component={Home}/> 
    <Route path="/repos" component={Repos}> 
     <Route path="/repos/:userName/:repoName" component={Repo}/> 
    </Route> 
    <Route path="/about" component={About}/> 
    </Route> 
) 

沒有名字 - 這正是混淆了我

1

這個問題被張貼here

在AppActions更改

module.exports = alt.createActions(AppActions); 

要:

export default alt.createActions(AppActions); 

使WebStorm快樂,不似乎打破了任何東西。