Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native and Cache #363

Open
magnuskrona opened this issue Mar 10, 2022 · 0 comments
Open

React Native and Cache #363

magnuskrona opened this issue Mar 10, 2022 · 0 comments

Comments

@magnuskrona
Copy link

magnuskrona commented Mar 10, 2022

Hi!

Describe the bug

I have a question about React Native and cache. I have set the cacheLife option to enable the cache. Even if the value is set, there is always a network request made.
But, if I enable debugging in the app with for example React Native Debugger and enable Network Inspect, the cache mechanism seems to work like it should. The data is cached for the amount of time set in the options. But as soon as I disable the debugger, nothing is cached again.

I'm using a Provider to set the url and the options:
<Provider url={API_URL} options={options}> {children} </Provider>

Setting up with useFetch:
const { get, post, response, loading, error } = useFetch(API_URL);

Calling get:
const myData = await get('/api/mydata?filter=' + filter);

Expected behavior
Setting the cacheLife option > 0 should cache the data in React Native

Any idea why this could be happening? I have tried on both simulator and device and it's the same problem on both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant