2016-05-19 40 views
2

を、I以下.babelrcファイルました:壊れた自動バインディング反応し、ネイティブとを使用して反応させ、リレーので、私はネイティブ反応し、反応するリレーを使用してい

{ 
    "sourceMaps": "both", 
    "presets": [ 
    "./plugins/babelRelayPlugin", 
    "react-native" 
    ], 
    "passPerPreset": true 
} 

をreact-native-material-kit(https://github.com/xinthink/react-native-material-kit)からのMKIconToggleが矢印で正しく機能しなくなり、この参照が失われたり間違ったりするため、コンポーネント内で矢印機能を使用する依存関係を追加します。最終的にエラーが発生し

元のコードは次のようになります

_onLayout = (evt) => { 
    this._onLayoutChange(evt.nativeEvent.layout); 

    if (this.props.onLayout) { 
     this.props.onLayout(evt); 
    } 
    }; 

エラーの場合に影響を受けるコードフラグメント:

d(55, function(global, require, module, exports) {var _this = this, 
    _jsxFileName = '.../node_modules/react-native-material-kit/lib/mdl/Ripple.js'; 
var Ripple = function (_Component) { 
    babelHelpers.inherits(Ripple, _Component); 

    function Ripple(props) { 
    babelHelpers.classCallCheck(this, Ripple); 

    var _this2 = babelHelpers.possibleConstructorReturn(this, Object.getPrototypeOf(Ripple).call(this, props)); 

    _this2._onLayout = function (evt) { 
     _this._onLayoutChange(evt.nativeEvent.layout); 

     if (_this.props.onLayout) { 
     _this.props.onLayout(evt); 
     } 
    }; 

_this参照が原因使用するには、ウィンドウに等しいです(_onLayout)

babelrcファイルを削除してデフォルトの実行を削除すると私は、次のtranspiled JSを取得し、それが動作します:

__d(921, function(global, require, module, exports) {var jsxFileName='...../node_modules/react-native-material-kit/lib/mdl/Ripple.js'; 

Component=React.Component;var Animated=React.Animated;var View=React.View;var PropTypes=React.PropTypes;var Platform=React.Platform;var Ripple=function(_Component){ 
babelHelpers.inherits(Ripple,_Component); 
function Ripple(props){babelHelpers.classCallCheck(this,Ripple); 
var _this=babelHelpers.possibleConstructorReturn(this,Object.getPrototypeOf(Ripple).call(this, props)); 
_this._onLayout=function(evt){ 
_this._onLayoutChange(evt.nativeEvent.layout); 

if(_this.props.onLayout){ 
_this.props.onLayout(evt);}};_this. 

私は、問題の原因を本当にかどうか分からないが、私はコンストラクタで機能を結合することによってそれを修正することができますが、私はむしろ、直接の依存関係のコードを変更しないと思います。 私は既にバベルのconfに様々なプリセットを追加しようとしました:es2015、stage-0、babel-preset-react-native-stage-0など、運がないものもあります。

面白いことに、矢印の機能を持つ単一のコンポーネントを作成してもまだ動作するbabelrcを使用すると、この動作はすべての依存関係で発生せず、独自のコードでも発生しません。

この動作を100%再現することはできません。他の依存関係も見たことがありますが、一度発生しても通常はもう離れることはありません。

+0

修正しましたか? –

答えて

0

バベルプリセット反応ネイティブステージ0でした。 キャッシュに残った内容や他の場所をすべてクリアした後で、わからないことがあります。 watchman watch-del-all rm -rf $TMPDIR/react-* rm -rf node_modules npm install npm start --reset-cache 私のプロジェクトとすべての矢印機能が動作します。

関連する問題