Skip to content

Option to disable or differentiate if returned data does not match query variables #1424

Answered by phryneas
niekert asked this question in Q&A
Discussion options

You must be logged in to vote

The easiest way of achieving that would simply be to reset your component's identity - after all you probably also don't want to keep other local state around for it.

That could be done just by adding a key prop: <PersonLoader id={selectedPerson} key={selectedPerson} />.

Another point would be just to use a selector

apiSlice.useGetPersonQuery({ id }, { pollingInterval: 2000 }); // just to make the request
const selector = useMemo(() => api.endpoints.getPerson.select(id), [id])
const result = useSelector(selector) // and getting the data

Generally, this has been asked for a few times (e.g. #1339) and we'll probably add a boolean flag on result in a future version, but as of right now, thi…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@niekert
Comment options

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