0
私は開始しようとしているがfirebaseBlog上の例以下、反応して、私は次のコードを実行してみました、私はReactFire:Uncaught SyntaxError:予期しないトークン| componentWillMount
Uncaught SyntaxError: http://localhost/h/js/test.js: Unexpected token (1:28)
> 1 | componentWillMount: function() {
| ^
2 | this.firebaseRef = firebase.database().ref("items");
3 | this.firebaseRef.on("child_added", function(dataSnapshot) {
4 | this.items.push(dataSnapshot.val());
、取得し、コードがこれであるために呼ばれています。
componentWillMount: function() {
this.firebaseRef = firebase.database().ref("items");
this.firebaseRef.on("child_added", function(dataSnapshot) {
this.items.push(dataSnapshot.val());
this.setState({items: this.items});
}.bind(this)
);
}
'firebaseBlog'の例は、より具体的に、どういう例ですか?このスニペットは有効な反応コンポーネントの一部ですが、残りのコンポーネント宣言はまだ必要です。 – loganfsmyth