Skip to content

Is it ok to use initialData with previousData? #8834

Answered by TkDodo
moroshko asked this question in Q&A
Discussion options

You must be logged in to vote

Could you explain why the highlightQuery is updated too early?

what do you mean with too early? From what I can see, everything is fine in the sandbox.

I type in “a”. This creates a new query with “fruits, a”, and I get back:

{
  "isFetching": true,
  "fruits": [
    "Banana",
    "Blackberry"
  ],
  "highlightQuery": "a"
}

those values come from the initialData passed, which is fine.

Then I type “b”. The query is now “ab”, so it creates a new query “fruits, ab”. That again gets initialData (because that’s what the code does - it’s a completely new query), so we get:

{
  "isFetching": true,
  "fruits": [
    "Banana",
    "Blackberry"
  ],
  "highlightQuery": "ab"
}

if you’d expected h…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@TkDodo
Comment options

@TkDodo
Comment options

@moroshko
Comment options

@TkDodo
Comment options

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