Skip to content

Is it possible to re-render the Server Component when the Query State changes? #351

Answered by franky47
lamualfa asked this question in Q&A
Discussion options

You must be logged in to vote

Try this:

const [unsafeValue, setValue] = useQueryState('q')
  .withOptions({ shallow: false })
  .withDefault('') // May I recommend this change too, to turn null into empty strings and simplify logic later

Shallow mode is on by default (client-only updates), you have to opt-in to notifying the server.

If you are connecting this to a database query, you might want to run the parser on the server too.

FYI, for high-frequency updates like text inputs, you won't receive a request per character typed. Instead, they'll be batched and throttled at around 50ms. This should help avoid overloading your server and/or database.

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@lamualfa
Comment options

@franky47
Comment options

@lamualfa
Comment options

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