Skip to content

Commit

Permalink
fix(ChartKit): id not to be new on every render (#76)
Browse files Browse the repository at this point in the history
Co-authored-by: Anton Standrik <astandrik@yandex-team.ru>
  • Loading branch information
astandrik and Anton Standrik authored Nov 30, 2022
1 parent ddedbd1 commit 230a992
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/ChartKit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ type ChartKitComponentProps<T extends ChartKitType> = Omit<ChartKitProps<T>, 'on

const ChartKitComponent = <T extends ChartKitType>(props: ChartKitComponentProps<T>) => {
const widgetRef = React.useRef<ChartKitWidgetRef>();
const {instanceRef, id = getRandomCKId(), type, data, onLoad, isMobile, ...restProps} = props;
const {instanceRef, id: propsId, type, data, onLoad, isMobile, ...restProps} = props;

const ckId = React.useMemo(() => getRandomCKId(), []);
const id = propsId || ckId;

const lang = settings.get('lang');
const plugins = settings.get('plugins');
const plugin = plugins.find((iteratedPlugin) => iteratedPlugin.type === type);
Expand Down

0 comments on commit 230a992

Please sign in to comment.