Skip to content

Commit

Permalink
fix: update component map mering
Browse files Browse the repository at this point in the history
  • Loading branch information
DC-RomanKarpov committed Dec 1, 2023
1 parent 3e72ac1 commit d3a98f5
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions src/hooks/useExtendedComponentMap.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import {useMemo} from 'react';

import {CustomConfig} from '@gravity-ui/page-constructor';
import {CustomConfig, getCustomItems} from '@gravity-ui/page-constructor';

import componentMap from '../constructor/blocksMap';

export const useExtendedComponentMap = (custom: CustomConfig | undefined) =>
useMemo(
() =>
custom
? {
...custom,
blocks: custom.blocks
? {...componentMap.blocks, ...custom.blocks}
: componentMap.blocks,
headers: custom.headers
? {...componentMap.headers, ...custom.headers}
: componentMap.headers,
}
: componentMap,
() => ({
...custom,
blocks: {...componentMap.blocks, ...getCustomItems(['blocks'], custom)},
headers: {...componentMap.headers, ...getCustomItems(['headers'], custom)},
}),
[custom],
);

0 comments on commit d3a98f5

Please sign in to comment.