refactor(Project): split out components into their own files

This commit is contained in:
Jordan Knott
2021-04-30 20:06:05 -05:00
parent bd34f4b3ad
commit 3e72271d9b
9 changed files with 326 additions and 374 deletions

View File

@ -0,0 +1,13 @@
import React from 'react';
const useStateWithLocalStorage = (localStorageKey: string): [string, React.Dispatch<React.SetStateAction<string>>] => {
const [value, setValue] = React.useState<string>(localStorage.getItem(localStorageKey) || '');
React.useEffect(() => {
localStorage.setItem(localStorageKey, value);
}, [value]);
return [value, setValue];
};
export default useStateWithLocalStorage;

View File

@ -0,0 +1,5 @@
const RFC2822_EMAIL = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/;
export default function isValidEmail(target: string) {
return RFC2822_EMAIL.test(target);
}

View File

@ -0,0 +1,5 @@
const localStorage = {
CARD_LABEL_VARIANT_STORAGE_KEY: 'card_label_variant',
};
export default localStorage;