How to refetch Prismic content with useSinglePrismicDocument (and other hooks)

Hi all,

I've been using the Prismic hooks like useSinglePrismicDocument etc. They're working great and make developing with React / Prismic so easy.

However I have a problem where I need to periodically refresh the content that I'm displaying (that's being sourced from Prismic).

Obviously because the content that is returned by the hooks are stateful this is proving difficult to achieve.

Any idea how I can force a refresh of my content using the hooks?

Regards, John.

Wait maybe I can use the usePrismicClient to achieve this?

Yes this has worked. For anyone else interested obviously the usePrismic* hooks are stateful, so you can't really fetch a new batch easily.

So I just manually set up some state and populated it using the fetch methods of the prismicClient object (obtained with usePrismicClient).

Hello @john2

I am glad that you have figured it out. Let us know if you have any other questions.