Skip to content

has this library built-in cache? #40

Answered by iduuck
Javier-Szyfer asked this question in Q&A
Discussion options

You must be logged in to vote

No, not (yet?) – we are currently only using the state for response. BUT, you could connect swr and wagmi to get the best of both worlds. Since swr is accepting promises, you could easily use the read function, which is being returned by the useContractRead and let swr cache it inside it's system.

const ComponentName = () => {
  // example from docs: https://wagmi-xyz.vercel.app/docs/hooks/useContractRead#usage
  const [_, read] = useContractRead(
    {
      addressOrName: '0xecb504d39723b0be0e3a9aa33d646642d1051ee1',
      contractInterface: wagmigotchiABI,
    },
    'getHunger',
  )

  // example from swr docs: https://swr.vercel.app/docs/data-fetching#fetch
  const { data } = useSWR('…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Javier-Szyfer
Comment options

Answer selected by Javier-Szyfer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants