This file contains hidden or 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
<?php | |
namespace App\Traits; | |
use Intervention\Image\Facades\Image; | |
use ImageKit\ImageKit; | |
trait ImageKitUtility | |
{ | |
//Upload to imagekit |
This file contains hidden or 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 { useState } from 'react'; | |
export default function usePersistedState<T>( | |
key: string, | |
initialValue: T | |
): [T, React.Dispatch<React.SetStateAction<T>>] { | |
// Initialize state with a function to avoid unnecessary localStorage calls | |
const [value, setValueState] = useState<T>(() => { | |
try { | |
const item = localStorage.getItem(key); |