GETリクエスト(オブジェクトの配列)からの応答を取得し、その状態を配列 'templates'に設定しようとしています。そのようなstate.templates、:私はSETSTATEラインをコメントアウトし、ちょうど応答をログコンソールがある場合React Native this2.stateエラー
fetch('https://tiy-warmup.herokuapp.com/api/templates?token=' +
token)
.then(response => response.json())
.then(response => this.setState({templates: response}))
// .then(response => console.log(response))
は、私は戻って、正しい配列を取得するので、私は私のフェッチが良好であることを知っています。私はSETSTATEラインを実行しようとすると、しかし、私はこのエラーを取得する:
Possible Unhandled Promise Rejection (id: 0):
_this2.setState is not a function
このエラーを歩き回ると、レンダリングにthis.state.templatesを使用することができることに解決策になりますか?
はありがとうを取ります!矢印機能が働いた。 –