Comments (8)
Okay that makes sense now. So this would be a breaking change if we change the manual query to use the cache by default. Let me think if there is a non-breaking way to introduce it, otherwise I'll have to bump major.
from axios-hooks.
I'd suggest giving users an option to opt in to caching for the standard or refetch behaviour, but its your call; I won't be surprised if someone asks for caching to be switchable for the standard hook behaviour.
I'll review the PR as it sounds like it'll fix the problem I have in my scenario.
from axios-hooks.
Not sure I see understand the scenario. The assumption is that if you execute the query manually, then surely you want to execute it, right?
from axios-hooks.
Not sure I see understand the scenario. The assumption is that if you execute the query manually, then surely you want to execute it, right?
So I have a page using a input control. When I enter data into the control it triggers an onChange event where the handler then makes use of execute (returned from useAxios). If a user deletes text from the control then execute will correctly get called, however I'd like to use a cached result instead of going back to the server to recalculate the result.
from axios-hooks.
Yes, either the behaviour of manual option would need to change or you'd need to introduce an additional option to control the caching.
The minor criticism I have (the work you've done on this repo is great!) is that I'd expect consumers (e.g. me!) would expect that the manual option just controls whether the hook runs automatically or not. I was surprised when I looked at the code to find that as well as doing this is also implicitly controls the caching behaviour. Hence a re-think in this area maybe warranted.
from axios-hooks.
@8enSmith fair point. the reason why it behaves like that is that historically that function was called refetch
and it was used to, well, refetch the data of a query, and for that reason no caching in there was the only sensible behavior. Once the manual option was introduced that's not the only sensible behavior anymore though, but that's where it's coming from.
from axios-hooks.
@8enSmith can you have a look at #20 and let me know what you think? briefly, I extended the signature of the "refetch" function to accept an optional second parameter (the first is axios options overrides and needs to stay there) which allows to use the cache. it's off by default to avoid breaking changes and because I still think that it's the safe default
from axios-hooks.
Opened an issue at #33 for that scenario :)
from axios-hooks.
Related Issues (20)
- Release pending!
- Refetch "expression is not callable" HOT 2
- Why I'm getting 2 rendered using this hook, when component mounts? HOT 9
- Release pending!
- Prevent CanceledError and redundant HTTP calls for identical request data HOT 1
- Support for API polling HOT 1
- type error HOT 9
- Uncaught TypeError: object is not iterable (cannot read property Symbol(Symbol.iterator)) HOT 1
- How to configure SSR with NextJS? HOT 3
- "Uncaught runtime errors: Cannot read properties of undefined (reading 'data')" after upgrading to CRA 5.0.1 & Node 18 HOT 6
- Not usable within the US? HOT 1
- Error from a dynamically loaded uri HOT 3
- Release pending!
- Release pending!
- useAxios hook sending in 2 requests, the first is cancelled immediately HOT 3
- Release pending! HOT 3
- Release pending!
- Release pending!
- Type error: MouseEvent using refetch and provided example from docs HOT 2
- Still an issue with both `executeGet` and `execute` methods when executed manually HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from axios-hooks.