Skip to content

Commit

Permalink
#75 Added jsdoc for useRedirectTo.
Browse files Browse the repository at this point in the history
  • Loading branch information
artzub committed Feb 3, 2022
1 parent 629036c commit 7919ac5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/models/UrlPartTypes.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* Types of url parts
* @readonly
* @enum {string}
*/
export const UrlPratTypes = {
service: 'service',
profile: 'profile',
Expand Down
10 changes: 7 additions & 3 deletions src/shared/hooks/useRedirectTo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ const order = [
UrlPratTypes.commits,
];

export const useRedirectTo = (partType) => {
/**
* @param {UrlPratTypes} urlPartType
* @return {function(string): void}
*/
export const useRedirectTo = (urlPartType) => {
const history = useHistory();
const {
service,
Expand All @@ -32,7 +36,7 @@ export const useRedirectTo = (partType) => {

return useCallback(
(part) => {
const index = order.indexOf(partType);
const index = order.indexOf(urlPartType);
if (index < 0) {
return;
}
Expand All @@ -42,6 +46,6 @@ export const useRedirectTo = (partType) => {

history.push(`${url}/${part}`);
},
[hash, history, partType],
[hash, history, urlPartType],
);
};

0 comments on commit 7919ac5

Please sign in to comment.