2017-04-26 33 views
2

我試圖創建一個無狀態的功能組件在反應,但它看起來像巴貝爾有一些麻煩transpiling。片段export default AppLayout =() => {};被轉譯爲exports.default = AppLayout = function AppLayout() {};,其中給出以下錯誤Uncaught ReferenceError: AppLayout is not defined巴貝爾錯誤地transpiles出口默認函數

我正在使用以下預設運行babel stage-0,es2015react。我在流星中使用了這個語法,所以我猜測它是我缺少的一個模塊。

回答

2

這也應該工作

const MyComponent =() => <div>Hi</div> 
export default MyComponent; 

或一個襯墊

export default() => <div>Hi</div> 
+0

謝謝你,我怎麼就不能在一個行它 – svendjokumsen

+0

如果不給一個名字:出口默認值()=>

Hi