Skip to content

Conversation

@Arthurgallina1
Copy link
Contributor

This PR is related to #33

  • Adds useQueryParams hook that gets and sets query params;
  • Adds docs, usage example and unit tests for it.

@Arthurgallina1 Arthurgallina1 changed the title Use query params Add useQueryParams hook Sep 16, 2021
export default function useQueryParams() {
const {
replace, search,
} = useLocation();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

way to reuse your useLocation hook!

};

const setParams = (params) => {
const stringfiedUrlSearchParams = new URLSearchParams(params).toString();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clean. Love it

@craig1123 craig1123 merged commit 741d934 into craig1123:master Sep 16, 2021
@craig1123 craig1123 mentioned this pull request Sep 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants