Skip to content

Commit 775a157

Browse files
authored
Update README.md (#237)
Fixed the handling of the searchParams return type and convert it from String to Number in order to increment it. Default to 0 if parameter not defined yet. The handling of the empty page String in the setSearchParams feels cleaner than initializing the page to 0, as the parameter is mostly used after the first page.
1 parent 3332983 commit 775a157

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ const [searchParams, setSearchParams] = useSearchParams();
533533
return (
534534
<div>
535535
<span>Page: {searchParams.page}</span>
536-
<button onClick={() => setSearchParams({ page: searchParams.page + 1 })}>Next Page</button>
536+
<button onClick={() => setSearchParams({ page: (parseInt(searchParams.page) || 0) + 1 })}>Next Page</button>
537537
</div>
538538
);
539539
```

0 commit comments

Comments
 (0)