This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useForm = initialValues => { | |
const [values, setValues] = React.useState(initialValues); | |
return [ | |
values, | |
e => { | |
setValues({ | |
...values, | |
[e.target.name]: e.target.value | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const useLocalStorage = (keyName, defaultValue) => { | |
const [storedValue, setStoredValue] = React.useState(() => { | |
try { | |
const value = window.localStorage.getItem(keyName); | |
if (value) { | |
return JSON.parse(value); | |
} else { | |
window.localStorage.setItem(keyName, JSON.stringify(defaultValue)); | |
return defaultValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const LazyLoadImage = ({ | |
alt, | |
src, | |
className, | |
loadInitially = false, | |
observerOptions = { root: null, rootMargin: '200px 0px' }, | |
...props | |
}) => { | |
const observerRef = React.useRef(null); | |
const imgRef = React.useRef(null); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////////////////////////////////// | |
// all coutries lists | |
////////////////////////////////// | |
export const countryOptions = [ | |
{ value: "Afghanistan", label: "Afghanistan" }, | |
{ value: "Åland Islands", label: "Åland Islands" }, | |
{ value: "Albania", label: "Albania" }, | |
{ value: "Algeria", label: "Algeria" }, | |
{ value: "American Samoa", label: "American Samoa" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useQuery, useQueryClient } from 'react-query'; | |
// Inside your component or function... | |
const queryClient = useQueryClient(); | |
// Example: Invalidate a single query | |
queryClient.invalidateQueries('yourQueryKey'); | |
// Example: Invalidate multiple queries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import react from '@vitejs/plugin-react'; | |
import svgr from "vite-plugin-svgr"; | |
export default { | |
plugins: [react(), svgr()], | |
server: { | |
port: 8081, | |
}, | |
resolve: { | |
alias: [ |