9 Commits

Author SHA1 Message Date
Simone Busoli
0b3b32e143
chore: upgrade eslint babel parser (#689) 2022-01-03 15:24:03 +01:00
Simone Busoli
fff9ffed1f feat: store response in cache when skipping cache for request
BREAKING CHANGE:

This release introduces a fundamental change in the caching mechanism.

The main difference is that requests that don't use the cache
will store the response in the cache anyway, making the behavior
of the library more intuitive and predictable.

In other words, `{ useCache: false }` will only skip _reading_ from the cache,
but it will write the response to the cache in any case.

The docs contain a caching example providing a full overview of
how the new caching behavior works.

A potential side effect of the new behavior, which we tried mitigating,
is that the `refetch` function returned by the hook, which was always
skipping the cache previously, now stores the response in cache.
Because of this, it must generate a key for the cache, which is created
based on the configuration provided as the first argument to the `refetch`
function itself.

Because the `refetch` function is often provided directly to DOM event handlers:

```
<button onClick={refetch} />
```

this would no longer work because the first argument will be the React event and
we cannot generate a cache key from that, and it wouldn't make much sense either.
Because this is a fairly common scenario, we implemented a specific handling for
this case. If the first argument is an event, it is ignored and considered as if
no configuration override was provided.
2020-06-24 18:13:31 +02:00
Simone Busoli
2b0e9a58ed feat: support multiple instances of useAxios configured independently
See README for details about how to use the feature: https://github.com/simoneb/axios-hooks/#multiple-hook-instances

fix #98
2019-11-30 22:48:26 +01:00
Simone Busoli
5f32d1749f chore(build): skip test files from bundle and output cjs in cjs folder 2019-11-08 00:40:50 +01:00
Simone Busoli
88829b0206 fix: do not execute manual requests on server 2019-10-19 17:24:01 +02:00
Simone Busoli
076f89a267 refactor: Add tests to check that typescript definitions are correct
Fixes #23
2019-08-05 19:48:20 +02:00
Simone Busoli
c6535e7d57 0.3.1 2019-02-17 12:23:39 +01:00
Simone Busoli
8c44970188 0.1.2 2019-02-16 18:41:48 +01:00
Simone Busoli
8329ccef48 Initial commit from nwb v0.23.0 2019-02-16 17:48:57 +01:00