Open
Description
Hey!
I've encountered this problem lately and I was wondering what could I do with that.
I have this piece of code
import * as React from 'react'
import { useGetPokemonByNameQuery } from './services/pokemon'
export default function App() {
const { isLoading } = useGetPokemonByNameQuery('bulbasaur')
return (
<div className="App">
{isLoading ? 'Loading...' : <Pokemon name={'bulbasaur'} />}
</div>
)
}
export const Pokemon = ({ name }: { name: string }) => {
const {} = useGetPokemonByNameQuery(name)
return (
<div>
Pokemon
</div>
)
}
Link to codesanbox: LINK
Basically the theme here is:
- I want to preload some data, therefore I use
useGetPokemonByNameQuery
in parent component - When the data is loading I'm not rendering child component.
- When the data is preloaded I want to display the data in child component using the same hook
And everything works well when the request was succesful.
Unfortunately when the request fails continuously (like in the sandbox there is wrong URL) there is infinite loop of requests coming from RTK query
I was wondering if you could help me with solution here?