From 8814e5ee6be3364a2d5644cf8994b4fcb9653760 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Sun, 18 Feb 2024 19:01:50 +0100 Subject: [PATCH] [core] Fix missing context display names --- packages/x-charts/src/Gauge/GaugeProvider.tsx | 4 ++++ .../src/context/CartesianContextProvider.tsx | 4 ++++ packages/x-charts/src/context/DrawingProvider.tsx | 15 ++++++++++++--- .../x-charts/src/context/HighlightProvider.tsx | 4 ++++ .../x-charts/src/context/InteractionProvider.tsx | 4 ++++ .../src/context/SeriesContextProvider.tsx | 4 ++++ .../LicenseInfoContext.ts | 8 +++++++- 7 files changed, 39 insertions(+), 4 deletions(-) diff --git a/packages/x-charts/src/Gauge/GaugeProvider.tsx b/packages/x-charts/src/Gauge/GaugeProvider.tsx index ffdb99ecb0df6..d89f938906f06 100644 --- a/packages/x-charts/src/Gauge/GaugeProvider.tsx +++ b/packages/x-charts/src/Gauge/GaugeProvider.tsx @@ -125,6 +125,10 @@ export const GaugeContext = React.createContext< valueAngle: null, }); +if (process.env.NODE_ENV !== 'production') { + GaugeContext.displayName = 'GaugeContext'; +} + export interface GaugeProviderProps extends GaugeConfig, CircularConfig { children: React.ReactNode; } diff --git a/packages/x-charts/src/context/CartesianContextProvider.tsx b/packages/x-charts/src/context/CartesianContextProvider.tsx index e40509396e772..f225db07b11e3 100644 --- a/packages/x-charts/src/context/CartesianContextProvider.tsx +++ b/packages/x-charts/src/context/CartesianContextProvider.tsx @@ -90,6 +90,10 @@ export const CartesianContext = React.createContext<{ // @ts-ignore }>({ xAxis: {}, yAxis: {}, xAxisIds: [], yAxisIds: [] }); +if (process.env.NODE_ENV !== 'production') { + CartesianContext.displayName = 'CartesianContext'; +} + function CartesianContextProvider(props: CartesianContextProviderProps) { const { xAxis: inXAxis, yAxis: inYAxis, dataset, children } = props; const formattedSeries = React.useContext(SeriesContext); diff --git a/packages/x-charts/src/context/DrawingProvider.tsx b/packages/x-charts/src/context/DrawingProvider.tsx index 9e4047e57c02a..234092081472e 100644 --- a/packages/x-charts/src/context/DrawingProvider.tsx +++ b/packages/x-charts/src/context/DrawingProvider.tsx @@ -54,7 +54,16 @@ export const DrawingContext = React.createContext< width: 400, chartId: '', }); -export const SVGContext = React.createContext>({ current: null }); + +if (process.env.NODE_ENV !== 'production') { + DrawingContext.displayName = 'DrawingContext'; +} + +export const SvgContext = React.createContext>({ current: null }); + +if (process.env.NODE_ENV !== 'production') { + SvgContext.displayName = 'SvgContext'; +} function DrawingProvider(props: DrawingProviderProps) { const { width, height, margin, svgRef, children } = props; @@ -67,9 +76,9 @@ function DrawingProvider(props: DrawingProviderProps) { ); return ( - + {children} - + ); } diff --git a/packages/x-charts/src/context/HighlightProvider.tsx b/packages/x-charts/src/context/HighlightProvider.tsx index 24d1ed155fca4..2a0d8080afac4 100644 --- a/packages/x-charts/src/context/HighlightProvider.tsx +++ b/packages/x-charts/src/context/HighlightProvider.tsx @@ -56,6 +56,10 @@ export const HighlighContext = React.createContext({ dispatch: () => null, }); +if (process.env.NODE_ENV !== 'production') { + HighlighContext.displayName = 'HighlighContext'; +} + const dataReducer: React.Reducer, HighlighActions> = ( prevState, action, diff --git a/packages/x-charts/src/context/InteractionProvider.tsx b/packages/x-charts/src/context/InteractionProvider.tsx index 0e478d13a09a2..2c26dc32aea9d 100644 --- a/packages/x-charts/src/context/InteractionProvider.tsx +++ b/packages/x-charts/src/context/InteractionProvider.tsx @@ -63,6 +63,10 @@ export const InteractionContext = React.createContext({ dispatch: () => null, }); +if (process.env.NODE_ENV !== 'production') { + InteractionContext.displayName = 'InteractionContext'; +} + const dataReducer: React.Reducer, InteractionActions> = ( prevState, action, diff --git a/packages/x-charts/src/context/SeriesContextProvider.tsx b/packages/x-charts/src/context/SeriesContextProvider.tsx index 6f8a9b9dc6283..b957fd6c38352 100644 --- a/packages/x-charts/src/context/SeriesContextProvider.tsx +++ b/packages/x-charts/src/context/SeriesContextProvider.tsx @@ -34,6 +34,10 @@ export type FormattedSeries = { [type in ChartSeriesType]?: FormatterResult({}); +if (process.env.NODE_ENV !== 'production') { + SeriesContext.displayName = 'SeriesContext'; +} + const seriesTypeFormatter: { [type in ChartSeriesType]?: (series: any, dataset?: DatasetType) => any; } = { diff --git a/packages/x-license/src/Unstable_LicenseInfoProvider/LicenseInfoContext.ts b/packages/x-license/src/Unstable_LicenseInfoProvider/LicenseInfoContext.ts index fd743b3a64855..d7fac9168da0d 100644 --- a/packages/x-license/src/Unstable_LicenseInfoProvider/LicenseInfoContext.ts +++ b/packages/x-license/src/Unstable_LicenseInfoProvider/LicenseInfoContext.ts @@ -1,4 +1,10 @@ import * as React from 'react'; import { MuiLicenseInfo } from '../utils/licenseInfo'; -export default React.createContext({ key: undefined }); +const MuiLicenseInfoContext = React.createContext({ key: undefined }); + +if (process.env.NODE_ENV !== 'production') { + MuiLicenseInfoContext.displayName = 'MuiLicenseInfoContext'; +} + +export default MuiLicenseInfoContext;