Skip to content
Snippets Groups Projects
Verified Commit c083a426 authored by Ulrik Røsby's avatar Ulrik Røsby
Browse files

fix: Remove uneeded remove func from useStorage

parent dcc20acf
No related branches found
No related tags found
No related merge requests found
import { Dispatch, SetStateAction, useCallback, useEffect, useState } from 'react'; import { Dispatch, SetStateAction, useEffect, useState } from 'react';
type StorageObject = typeof window.localStorage | typeof window.sessionStorage; type StorageObject = typeof window.localStorage | typeof window.sessionStorage;
// useStorage, useLocalStorage and useSessionStorage is taken from: // useStorage, useLocalStorage and useSessionStorage is taken from:
...@@ -14,8 +14,8 @@ function useStorage<ValueType>( ...@@ -14,8 +14,8 @@ function useStorage<ValueType>(
key: string, key: string,
defaultValue: ValueType, defaultValue: ValueType,
storageObject: StorageObject, storageObject: StorageObject,
): [ValueType | undefined, Dispatch<SetStateAction<ValueType | undefined>>, () => void] { ): [ValueType, Dispatch<SetStateAction<ValueType>>] {
const [value, setValue] = useState<ValueType | undefined>(() => { const [value, setValue] = useState<ValueType>(() => {
const jsonValue = storageObject.getItem(key); const jsonValue = storageObject.getItem(key);
if (jsonValue != null) return JSON.parse(jsonValue); if (jsonValue != null) return JSON.parse(jsonValue);
return defaultValue; return defaultValue;
...@@ -26,11 +26,7 @@ function useStorage<ValueType>( ...@@ -26,11 +26,7 @@ function useStorage<ValueType>(
storageObject.setItem(key, JSON.stringify(value)); storageObject.setItem(key, JSON.stringify(value));
}, [key, value, storageObject]); }, [key, value, storageObject]);
const remove = useCallback(() => { return [value, setValue];
setValue(undefined);
}, []);
return [value, setValue, remove];
} }
/** /**
......
...@@ -27,7 +27,7 @@ export default function FeatsVsFixesPage() { ...@@ -27,7 +27,7 @@ export default function FeatsVsFixesPage() {
]; ];
for (let i = 0; i < authorData.length; i++) { for (let i = 0; i < authorData.length; i++) {
if (selectedAuthors?.[i]) { if (selectedAuthors[i]) {
featsFixesGraphData[0].val += authorData[i].feats; featsFixesGraphData[0].val += authorData[i].feats;
featsFixesGraphData[1].val += authorData[i].fixes; featsFixesGraphData[1].val += authorData[i].fixes;
additionsDeletionsGraphData[0].val += authorData[i].additions; additionsDeletionsGraphData[0].val += authorData[i].additions;
...@@ -54,7 +54,7 @@ export default function FeatsVsFixesPage() { ...@@ -54,7 +54,7 @@ export default function FeatsVsFixesPage() {
<div key={JSON.stringify(m)}> <div key={JSON.stringify(m)}>
Person {i + 1} Person {i + 1}
<Checkbox <Checkbox
checked={selectedAuthors?.[i]} checked={selectedAuthors[i]}
onChange={() => { onChange={() => {
if (!selectedAuthors) return; // selectedAuthors will never be undefined if (!selectedAuthors) return; // selectedAuthors will never be undefined
const tempList = [...selectedAuthors]; const tempList = [...selectedAuthors];
......
...@@ -37,7 +37,6 @@ export default function TimePerIssueLabelPage() { ...@@ -37,7 +37,6 @@ export default function TimePerIssueLabelPage() {
useEffect(() => { useEffect(() => {
// If allIssueData or selected is null, something is not selected and or the data is not // If allIssueData or selected is null, something is not selected and or the data is not
if (allIssueData == null) return; if (allIssueData == null) return;
if (selected == null) return;
// Find the average time used to close an issue with one of the selected labels // Find the average time used to close an issue with one of the selected labels
const selectedArray = JSON.parse(selected); const selectedArray = JSON.parse(selected);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment