You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, my goal is to restrict a number parameter to a certain range, for pagination.
The range is <1, 200>
I want to heal the URL parameter in such a way:
E.g. 1: page=-1 => page=1
E.g. 2: page=ABC => page=1
E.g. 3: page=300 => page=200
E.g. 4: page=100 => page=100 (no healing needed)
Moreover, the default parameter is 1 and I use removeDefaultsFromUrl: true.
This code works for E.g. 3 & 4, but it doesn't entirely work for E.g. 1 & 2. The query returned by useQueryParams hook has correct, healed values, but the values don't change in the URL.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey, my goal is to restrict a number parameter to a certain range, for pagination.
The range is
<1, 200>
I want to heal the URL parameter in such a way:
E.g. 1:
page=-1
=>page=1
E.g. 2:
page=ABC
=>page=1
E.g. 3:
page=300
=>page=200
E.g. 4:
page=100
=>page=100
(no healing needed)Moreover, the default parameter is
1
and I useremoveDefaultsFromUrl: true
.The code looks like the following:
This code works for E.g. 3 & 4, but it doesn't entirely work for E.g. 1 & 2. The
query
returned byuseQueryParams
hook has correct, healed values, but the values don't change in the URL.Beta Was this translation helpful? Give feedback.
All reactions