useCallback
This commit is contained in:
@@ -56,7 +56,8 @@ const TestDataTable = () => {
|
||||
const [userId, setUserId] = useState(2);
|
||||
const [pageName, setPageName] = useState('loan');
|
||||
const [tableName, setTableName] = useState('loan_table');
|
||||
const {settingStore, hideAction, filterAction, sortAction} = useTableSetting();
|
||||
const {settingStore, hideAction, filterAction, sortAction, oldSorting} = useTableSetting();
|
||||
console.log(settingStore)
|
||||
|
||||
const columns = useMemo(
|
||||
() => [
|
||||
@@ -142,23 +143,24 @@ const TestDataTable = () => {
|
||||
hideAction(userId, pageName, tableName, settingValue);
|
||||
};
|
||||
const onSortingChange = (event) => {
|
||||
const settingValue = event();
|
||||
const settingValue = event(settingStore?.[userId]?.[pageName]?.[tableName]?.['sorts'] || []);
|
||||
sortAction(userId, pageName, tableName, settingValue);
|
||||
}
|
||||
|
||||
return <MaterialReactTable columns={columns}
|
||||
data={data}
|
||||
manualSorting={true}
|
||||
initialState={{
|
||||
columnVisibility: settingStore?.[userId]?.[pageName]?.[tableName]?.['hides'],
|
||||
sorting: settingStore?.[userId]?.[pageName]?.[tableName]?.['sorts'] || []
|
||||
}}
|
||||
state={{
|
||||
columnVisibility: settingStore?.[userId]?.[pageName]?.[tableName]?.['hides'],
|
||||
sorting: settingStore?.[userId]?.[pageName]?.[tableName]?.['sorts'] || []
|
||||
}}
|
||||
onColumnVisibilityChange={onColumnVisibilityChange}
|
||||
onSortingChange={onSortingChange}
|
||||
return <MaterialReactTable
|
||||
columns={columns}
|
||||
data={data}
|
||||
manualSorting={true}
|
||||
initialState={{
|
||||
columnVisibility: settingStore?.[userId]?.[pageName]?.[tableName]?.['hides'],
|
||||
sorting: settingStore?.[userId]?.[pageName]?.[tableName]?.['sorts'] || []
|
||||
}}
|
||||
state={{
|
||||
columnVisibility: settingStore?.[userId]?.[pageName]?.[tableName]?.['hides'],
|
||||
sorting: settingStore?.[userId]?.[pageName]?.[tableName]?.['sorts'] || []
|
||||
}}
|
||||
onColumnVisibilityChange={onColumnVisibilityChange}
|
||||
onSortingChange={onSortingChange}
|
||||
/>;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user