-1

I am using next with rtk query. I have this query getPosts where I fetch and display the posts now when I click on a single post a new page opens and I want to use selectFromResult here to select the post I want from getPosts data. Is this possible or can I only do this in a child of the original component?

juliomalves
  • 42,130
  • 20
  • 150
  • 146
H.b
  • 239
  • 2
  • 13

1 Answers1

1

I tried this and it will not work. This is because if you queried a single post from a different tab/window, then there will be no "posts" in the cache to select from.

for example if you just copy and paste the url localhost:3000/posts/1 into a new browser tab, it will result in undefined, until you navigate to a component that loads all posts, and then navigate back to the single post, then it will read from the cache this time, as long as you are doing all those steps in the same browser tab where the cache is shared.

Kachinga
  • 194
  • 1
  • 7