2017-08-29 10 views
0

私はいくつかのコンポーネントを追加したストーリーブックでプロジェクトを作成しました。 私はエラーstorybookからコンポーネントを使用するとaddComponentAsRefToエラーが発生する

Uncaught Error: addComponentAsRefTo(...): Only a ReactOwner can have refs. You might be adding a ref to a component that was not created inside a component's render method, or you have multiple copies of React loaded.

を取得し、別のプロジェクトでは、これらのコンポーネントを使用しようとすると

"build": "babel components --out-dir dist-es6 --source-maps inline", 

私.babelrcはこのようになりますように私は絵本を築く:私はエクスポート

{ 
"presets": [ 
    "es2015", // whichever presets your projects use should match here 
    "stage-0", 
    "react" 
], 
"plugins": [ 
    "transform-runtime", // for polyfills 
    "transform-react-remove-prop-types" // we use this to remove the propTypes 
]} 

私のコンポーネントは次のようなindex.jsファイルを持っています:

export { default as DateFilter } from './DateFilter'; 

私は、コンポーネントが含まれます:

import { DateFilter } from 'storybook/dist-es6'; 

私は私のプロジェクトでそれを使用するために童話中のNMPのリンクを行います。私はコンポーネントを見ることができますが、それはキャッチされていないエラーで失敗します。

どうすればよいですか?

答えて

0

問題はstorybookとnwbの組み合わせで問題でした。 ストーリーブックと私のプロジェクトの両方が反応したので、私はストーリーブックの反応を無視する必要がありました。

これは私が実際に

:) NWB取り出しエンドで

aliases: { 
    react: path.resolve('./node_modules/react'), 
    'react-dom': path.resolve('./node_modules/react-dom'), 
    'prop-types': path.resolve('./node_modules/prop-types') 
}, 

nwb.config.jsファイルに追加されました

関連する問題