1
APIコールをローカルにキャッシュすることができるかどうかはわかりません。そのため、アプリケーションを閉じて再起動すると、まだそこに残っています。 Reduxののthisページでreact native/reduxでapiリクエストをキャッシュすることはできますか?
私はこのようにミドルウェアをキャッシュすることが可能であることを見た:
loadData(userId) {
// Injected into props by React Redux `connect()` call:
let { dispatch, posts } = this.props
if (posts[userId]) {
// There is cached data! Don't do anything.
return
}
// Reducer can react to this action by setting
// `isFetching` and thus letting us show a spinner.
dispatch(loadPostsRequest(userId))
// Reducer can react to these actions by filling the `users`.
fetch(`http://myapi.com/users/${userId}/posts`).then(
response => dispatch(loadPostsSuccess(userId, response)),
error => dispatch(loadPostsFailure(userId, error))
)
}
は、私はそれを使用する必要がありますか?そして、アプリケーション終了後にキャッシュが残っていますか?
ありがとうございました!私は今試してみる。 –