Skip to content

SearchBar should use defaultValue, value or none? #826

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

You must be logged in to vote

I think I see the issue: by debouncing the state updater functions, and using a controlled input (value & onChange), you do end up with only the last character pressed. You would get the same behaviour from useState.

nuqs has support for throttling, which works a bit differently (emit the first character immediately, then batch updates every throttleMs). This gives you consistent updates, but for search you might want eventual updates, when the user stops typing for a while, which is what debouncing does.

Built-in debouncing support is planned (see #291, #373, #449), and should hopefully land some time early in the new year.

In the mean time, you could:

  1. Feed the initial value coming from…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@didemkkaslan
Comment options

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