Our pokemon detail query is hard coded to a single pokemon. We want to be able to click on any pokemon to navigate to that pokemons detail page. Making queries dynamic in RTK Query is as easy as passing the data into the hook destructuring that data in the query function.
Instructor: [0:00] We still have the problem that no matter where we click, we always get the Bulbasaur and point back. To change that, we have to pass in either the number of the Pokémon or the name of the Pokémon here in our URL. Let's make it variable. [0:17] Let's say we want to pass in a name here and now, we have to bring that name in here in some way. Let's pass it in as an argument. Now that this is set up, we can just pass it into the hook. We take this Pokémon name here and pass it as the argument named name into our hook.
[0:43] Looking back at the browser, if we cut GO Charmander now, we get that. It works.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!