Skip to content

Commit

Permalink
fix: add generic type to sticky state hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aramalipoor committed Mar 30, 2022
1 parent 7198660 commit 7e41444
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/react-common/src/hooks/useStickyState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";

export const useStickyState = (defaultValue: any, key: string) => {
const [value, setValue] = React.useState(() => {
export const useStickyState = <T>(defaultValue: any, key: string) => {
const [value, setValue] = React.useState<T>(() => {
const stickyValue = window.localStorage.getItem(key);
return stickyValue !== null ? JSON.parse(stickyValue) : defaultValue;
});
Expand Down

0 comments on commit 7e41444

Please sign in to comment.