Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export default function useOrderState(
storeKeyPrefix: string,
needSave: boolean,
options: IOrderOptions
) {
const storeKey = `${storeKeyPrefix}.order_options`
const [memoryOrderOptions, setMemoryOrderOptions] = useState(options)
const [localOrderOptions, setLocalOrderOptions] = useLocalStorageState(
storeKey,
options
)
const orderOptions = useMemo(
() => (needSave ? localOrderOptions : memoryOrderOptions),
[needSave, memoryOrderOptions, localOrderOptions]
)
function changeOrder(orderBy: string, desc: boolean) {
if (needSave) {
setLocalOrderOptions({
orderBy,
desc,
})
} else {
setMemoryOrderOptions({