Skip to content

Commit

Permalink
refactor(Table): Improved context merge with default value
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos Pinedo committed Dec 2, 2023
1 parent e7fa134 commit a1f324e
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions packages/table/src/core/Table/context.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import * as React from 'react';
import {
MeasuresConfig,
TableVisualOptions,
TextsType,
} from '../../declarations';
import { MeasuresConfig, TableOptionsProps } from '../../declarations';
import { merge } from 'lodash';

interface TableContextProps {
visualOptions?: TableVisualOptions;
texts?: TextsType;
export interface TableContextProps
extends Pick<TableOptionsProps, 'visualOptions' | 'texts'> {
measures: MeasuresConfig;
}

Expand Down Expand Up @@ -62,8 +58,7 @@ export const TableContextProvider = ({
value,
}: TableContextProviderProps) => {
const [context] = React.useState({
...defaultTableContext,
...value,
...merge({}, defaultTableContext, value),
});

return (
Expand Down

0 comments on commit a1f324e

Please sign in to comment.