2016-03-22 18 views
0

re-baseを使用して、Reactを使用してFirebaseアプリに接続しようとしています。私の問題は私のアプリが構築されている場合ということですFirebase Webのインポートが定義されていません

import React from 'react'; 
import Firebase from 'firebase'; 
const base = new Firebase('https://my-firebase-app.firebaseio.com'); 

export default class Home extends React.Component { 
    constructor(props) { 
    super(props); 

    this.state = { 
     data: {} 
    }; 
    } 

    componentDidMount() { 
    this.ref = base.syncState('coffees', { 
     context: this, 
     asArray: true, 
     state: 'coffees', 
     then:() => { 
     console.log('finished base.syncState') 
     } 
    }); 
    ... 
    } 

    componentWillUnmount(){ 
    base.removeBinding(this.ref); 
    } 

    render() { 
    ... 
    } 
} 

、私はこれらの線の近くに、Firebase APIで'n' is undefinedを取得しています:

};function Fa() { 
     return Math.floor(2147483648 * Math.random()).toString(36) + Math.abs(Math.floor(2147483648 * Math.random())^ja()).toString(36); 
    };var w;a: { 
     var Ga = n.navigator;if (Ga) { 
      var Ha = Ga.userAgent;if (Ha) { 
       w = Ha;break a; 
      } 
     }w = ""; 
    };function Ia() { 

ここ

は、コンポーネントがどのように見えるリアクト私のものですconst base='...'行をコメントアウトしても、エラーはスローされます。 A:Firebase APIファイルに何か問題があります B:Babel/Webpackは、そうしてはならないものをマングリングしています。しかし、webpackのBabelローダーをcompact: falseに設定しようとしましたが、無駄です。

最後に、ここで私のpackage.jsonを見てです:

"dependencies": { 
    "react": "^0.14.7", 
    "react-dom": "^0.14.7", 
    "react-router": "^2.0.1" 
}, 
"devDependencies": { 
    "babel-core": "^6.7.2", 
    "babel-loader": "^6.2.4", 
    "babel-preset-es2015": "^6.6.0", 
    "babel-preset-react": "^6.5.0", 
    "eslint": "^2.4.0", 
    "eslint-plugin-react": "^4.2.3", 
    "html-webpack-plugin": "^2.10.0", 
    "re-base": "^1.5.1", 
    "webpack": "^1.12.14", 
    "webpack-dev-server": "^1.14.1" 
} 

、これは全体のアプリは、私は、デバッグを開始する見当がつかないロード&を失敗するので、私はこだわっています。どんな洞察も素晴らしいだろう!

+0

クロス投稿:https://groups.google.com/forum/#!topic/firebase-talk/vPztQKZQHC0 –

答えて

0

私の1つの問題は、webpackの設定(私が投稿しなかったもの)でした。

私はbabel-loaderプラグインを使用しています。 excludeオプションを'/node_modules'に設定しました。この値を設定

module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, // note the absence of ' ' loader: 'babel-loader', query: { presets: ['react', 'es2015'] } } ] }

適切に私の問題を修正:ソリューションはbabel-loaderは今、このようなものになりますので、引用符を削除することでした。

関連する問題