This repository has been archived by the owner on Nov 15, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christian Engel
committed
Apr 12, 2019
1 parent
34a2659
commit 559c188
Showing
2 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from "react"; | ||
import { useQueryParams } from '../../dist'; | ||
|
||
const getRandomString = () => { | ||
const r = Math.random() * 1235172132118424 + 12351241; | ||
return r.toString(32); | ||
}; | ||
|
||
const QPTest = () => { | ||
const [params, setParams] = useQueryParams(); | ||
|
||
const setSome = () => setParams({ some: getRandomString() }); | ||
|
||
const setOthers = () => setParams({ others: getRandomString() }); | ||
|
||
const unsetSome = () => setParams({ some: undefined }); | ||
|
||
const unsetOthers = () => setParams({ others: undefined }); | ||
|
||
return ( | ||
<div> | ||
<div>{"Current Params: " + JSON.stringify(params, null, 2)}</div> | ||
|
||
<button onClick={setSome}>Set some</button> | ||
<button onClick={setOthers}>Set others</button> | ||
<br /> | ||
<button onClick={unsetSome}>Unset some</button> | ||
<button onClick={unsetOthers}>Unset others</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default QPTest; |