UNPKG

@mui/x-charts

Version:

The community edition of MUI X Charts components.

30 lines (29 loc) 684 B
'use client'; import _extends from "@babel/runtime/helpers/esm/extends"; import * as React from 'react'; import { createChartDefaultId } from "./useChartId.utils.mjs"; export const useChartId = ({ params, store }) => { React.useEffect(() => { if (params.id === undefined || params.id === store.state.id.providedChartId && store.state.id.chartId !== undefined) { return; } store.set('id', _extends({}, store.state.id, { chartId: params.id ?? createChartDefaultId() })); }, [store, params.id]); return {}; }; useChartId.params = { id: true }; useChartId.getInitialState = ({ id }) => ({ id: { chartId: id, providedChartId: id } });