File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,15 @@ export function useFilterParam(
1717 const search = useSearch ( { strict : false } ) ;
1818 const navigate = useNavigate ( ) ;
1919
20- const rawValue = ( search ?. [ paramName ] as string | undefined ) ?? defaultValue ;
21- const value = allowedValues . includes ( rawValue ) ? rawValue : defaultValue ;
20+ const rawCandidate =
21+ search && Object . prototype . hasOwnProperty . call ( search , paramName )
22+ ? ( search as Record < string , unknown > ) [ paramName ]
23+ : undefined ;
24+
25+ const value =
26+ typeof rawCandidate === 'string' && allowedValues . includes ( rawCandidate )
27+ ? rawCandidate
28+ : defaultValue ;
2229
2330 const setValue = ( newValue : string ) => {
2431 if ( ! allowedValues . includes ( newValue ) ) return ; // ignore invalid values
You can’t perform that action at this time.
0 commit comments