@mui/x-charts
Version:
The community edition of MUI X Charts components.
12 lines (11 loc) • 773 B
JavaScript
'use client';
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage";
import * as React from 'react';
import { ChartsContext } from "./ChartsContext.mjs";
export const useChartsContext = () => {
const context = React.useContext(ChartsContext);
if (context == null) {
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X Charts: Could not find the Charts context. ' + 'This happens when the component is rendered outside of a ChartsDataProvider or ChartsContainer parent component, ' + 'which means the required context is not available. ' + 'Wrap your component in a ChartsDataProvider or ChartsContainer. ' + 'This can also happen if you are bundling multiple versions of the library.' : _formatErrorMessage(30));
}
return context;
};