sannajammeh / trpc-swr

tRPC-ified SWR hooks
https://trpc-swr.vercel.app
MIT License
210 stars 5 forks source link

use mutate from SWRConfiguration context #8

Closed briancoit closed 2 years ago

briancoit commented 2 years ago

Currently createSWRHooks is limited to use of the global swr config (state/cache) which prevents us from being able to correctly make use of <SWRConfig /> since mutations would always apply to the global state rather than context state (where we'd be reading from). getUseMatchMutate already operates correctly on the config provided by the nearest context.

This change updates TRPCProvider to use useSWRConfig().mutate, which operates on the context state (where context is available) or falls back to global state.

sachinraja commented 2 years ago

released in 0.1.2