useCallback

This commit is contained in:
2024-02-18 14:42:45 +03:30
parent 0d35263ca2
commit e7ad977ede
2 changed files with 24 additions and 24 deletions

View File

@@ -1,24 +1,22 @@
'use client'
import {createContext, useEffect, useState} from "react";
import {createContext, useCallback, useEffect, useState} from "react";
export const TableSettingContext = createContext();
export const TableSettingProvider = ({children}) => {
const [settingStore, setSettingStore] = useState({});
useEffect(() => {
const _localStorage = localStorage.getItem("_setting-app")
if (_localStorage)
if (_localStorage) {
setSettingStore(JSON.parse(_localStorage))
}
}, []);
const hideAction = (user_id, page_name, table_name, settingValue) => {
const hideAction = useCallback((user_id, page_name, table_name, settingValue) => {
updateSettingStorage(user_id, page_name, table_name, "hides", settingValue);
}
const sortAction = (user_id, page_name, table_name, settingValue) => {
},[])
const sortAction = useCallback((user_id, page_name, table_name, settingValue) => {
updateSettingStorage(user_id, page_name, table_name, "sorts", settingValue);
}
},[])
const filterAction = (user_id, page_name, table_name, settingValue) => {
updateSettingStorage(user_id, page_name, table_name, "filters", settingValue);
}