Skip to content

Commit

Permalink
Merge branch 'master' of github.com:flow-typed/flow-typed into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Brianzchen committed May 11, 2023
2 parents 6912183 + a28ae95 commit 6d5bbbd
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
Expand Up @@ -437,7 +437,9 @@ declare module 'react-router-dom' {
| URLSearchParams;

declare type SetURLSearchParams = (
nextInit?: URLSearchParamsInit,
nextInit?:
| URLSearchParamsInit
| (prevSearchParam: URLSearchParams) => URLSearchParamsInit,
navigateOpts?: {|
replace?: boolean,
state?: any,
Expand Down
Expand Up @@ -25,6 +25,7 @@ import {
useMatches,
useRouteError,
useLoaderData,
useSearchParams,
} from 'react-router-dom';
import type {
AgnosticRouteMatch,
Expand Down Expand Up @@ -423,6 +424,36 @@ describe('react-router-dom', () => {
useLoaderData('test');
});

describe('useSearchParams', () => {
const [searchParams, setSearchParams] = useSearchParams();

describe('setSearchParams', () => {
it('accepts a new object', () => {
setSearchParams({
a: 'b',
});

// $FlowExpectedError[incompatible-call]
setSearchParams({
a: 1,
});
});

it('accepts a function', () => {
setSearchParams((pSearchParams) => {
return {
a: 'b',
}
});
});

it('cannot be passed anything', () => {
// $FlowExpectedError[incompatible-call]
setSearchParams(123);
})
});
});

// ----------------------------------/
// `react-router-dom` /
// ----------------------------------/
Expand Down

0 comments on commit 6d5bbbd

Please sign in to comment.