Skip to content
Discussion options

You must be logged in to vote

It's an interesting case for sure. I would usually advice to keep server state and client state separately, and don't move server state into local state:

const { data } = useQuery('key', fetchFn)

{ data && <MySortableComponent initialData={data} /> }

function MySortableComponent = ({ initialData }) => {
   const [sortedData, setSortedData] = React.useStatate(initialData)
}

The problem with this approach is that this completely ignores background re-fetches that react-query might do (refetchOnWindowFocus etc). If you want to ignore them for this use-case, you can turn them off via the settings and use this approach.

Modifying the cache, as you mentioned, is not good because it will als…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ssteuteville
Comment options

@TkDodo
Comment options

Answer selected by ssteuteville
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