Skip to content

Commit

Permalink
[useTableState]: make params optional
Browse files Browse the repository at this point in the history
  • Loading branch information
AlekseyManetov committed Nov 8, 2024
1 parent 4178705 commit 8c45722
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const personColumns: DataColumnProps<Person, number>[] = [
export default function WithTableExample() {
const { api } = useUuiContext();

const { tableState, setTableState } = useTableState<Person, any>({});
const { tableState, setTableState } = useTableState<Person, any>();

const dataSource = useLazyDataSource<Person, number, Person>(
{
Expand Down
2 changes: 1 addition & 1 deletion app/src/sandbox/tablePaged/DemoTablePaged.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function DemoTablePaged() {
const [isInfoPanelOpened, setIsInfoPanelOpened] = useState(false);
const closeInfoPanel = useCallback(() => setIsInfoPanelOpened(false), []);

const { tableState, setTableState } = useTableState<Person>({});
const { tableState, setTableState } = useTableState<Person>();

useEffect(() => {
setTableState({ ...tableState, page: 1, pageSize: 100 });
Expand Down
3 changes: 1 addition & 2 deletions app/src/sandbox/tasks/ProjectTasksDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ export function ProjectTasksDemo() {
onValueChange({ ...value, items: { ...value.items, [task.id]: task } });
};

// const { tableState, setTableState } = useTableState<any>({ columns });
const { tableState, setTableState } = useTableState({});
const { tableState, setTableState } = useTableState();

const dataSource = useArrayDataSource<Task, number, DataQueryFilter<Task>>(
{
Expand Down
2 changes: 1 addition & 1 deletion extra/src/ideas/useList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ function ArrayPlainList() {

// Tree, table state is supplied from useTableState
function TreeTable() {
const tableState = useTableState({ columns });
const tableState = useTableState();

const list = useList<MyItem, number>({
api: testApi,
Expand Down
2 changes: 1 addition & 1 deletion uui-core/src/hooks/useTableState/useTableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export interface UseTableStateHookParams<TFilter = Record<string, any>, TViewSta
extends UseTableStateHookBaseParams<TFilter, TViewState>, Partial<IEditable<DataTableState<TFilter, TViewState>>> {}

export const useTableState = <TFilter = Record<string, any>, TViewState = any>
(params: UseTableStateHookParams<TFilter, TViewState>): ITableState<TFilter, TViewState> => {
(params?: UseTableStateHookParams<TFilter, TViewState>): ITableState<TFilter, TViewState> => {
const context = useUuiContext();

const externalValue = useRef(params.value);
Expand Down

0 comments on commit 8c45722

Please sign in to comment.