2016-04-26 39 views
0

編輯:作者已修補它。React-fetch需要react-addons,但沒有反應/ addons文件夾

我開始使用react-fetch(嗯,努力),並試圖運行webpack的時候,我得到這個錯誤:

ERROR in ./~/react-fetch/build/react-fetch.js 
Module not found: Error: Cannot resolve 'file' or 'directory' E:\Users\Adrien\Documents\GitHub\brigad-admin-frontend/node_modules/react/addons in E:\Users\Adrien\Documents\GitHub\brigad-admin-frontend\node_modules\react-fetch\build 
@ ./~/react-fetch/build/react-fetch.js 17:19-42 

但是,作爲錯誤說,我沒有react/addons文件夾(我正在使用React 15.0.1)。

以前有人有過這個問題嗎?

在此先感謝。

PS:這是我webpack.config.js:

const webpack = require('webpack'); 
const path = require('path'); 

const nodeDir = `${__dirname}/node_modules`; 

const config = { 
    resolve: { 
    alias: { 
     react: `${nodeDir}/react`, 
     'react-dom': `${nodeDir}/react-dom`, 
     'react-router': `${nodeDir}/react-router`, 
     'react-fetch': `${nodeDir}/react-fetch`, 
     'react-bootstrap': `${nodeDir}/react-bootstrap`, 
     velocity: `${nodeDir}/velocity-animate`, 
     moment: `${nodeDir}/moment`, 
     slimscroll: `${nodeDir}/slimscroll`, 
    }, 
    }, 
    entry: { 
    routes: [ 
     'webpack-dev-server/client?http://localhost:3000', 
     'webpack/hot/only-dev-server', 
     './public/src/routes/js/main', 
    ], 
    vendors: [ 
     'react', 'react-dom', 'react-router', 'react-fetch', 'react-bootstrap', 
     'velocity', 'moment', 'slimscroll', 
    ], 
    // chartVendors: ['raphael', 'morris'], 
    }, 
    output: { 
    path: path.join(__dirname, 'public/dist'), 
    // publicPath: path.join(__dirname, 'public/dist/'), 
    filename: 'bundles/[name].bundle.js', 
    chunkFilename: 'chunks/[name].chunk.js', 
    }, 
    module: { 
    loaders: [ 
     { 
     test: /\.jsx?$/, 
     include: path.join(__dirname, 'public'), 
     loader: 'react-hot', 
     }, 
     { 
     test: /\.js$/, 
     include: path.resolve(__dirname, 'public'), 
     loader: 'babel', 
     }, 
     { 
     test: /\.css$/, 
     include: path.join(__dirname, 'public'), 
     loader: 'style!css-loader?modules&importLoaders=1' + 
     '&localIdentName=[name]__[local]___[hash:base64:5]', 
     }, 
    ], 
    }, 
    plugins: [ 
    new webpack.HotModuleReplacementPlugin(), 
    new webpack.optimize.CommonsChunkPlugin('vendors', './bundles/vendors.js', Infinity), 
    ], 
}; 

module.exports = config; 

回答

1

陣營API已經改變。 import React from 'react/addons'在當前版本中無效。我可以看到作者從那裏使用React.addons.cloneWithProps

The documentation建議使用React.cloneElement來代替。

您可以相應地調整代碼並提交一個PR來解決這個問題。

+0

明天早上我會試試看,謝謝:) – Zephir77167

+0

好吧,事實證明我沒有足夠的實驗來調整代碼,我只是打開一個問題。 – Zephir77167

+0

我有這個想法[這裏](https://gist.github.com/bebraw/77c8168e54a4ce3257f9)。也許你可以根據這個和PR來調整代碼。 –

相關問題