[charts] Add environment check for warning messages in axis and radar hooks#22506
Conversation
Deploy previewhttps://deploy-preview-22506--material-ui-x.netlify.app/ Bundle size
PerformanceTotal duration: 941.06 ms +16.51 ms(+1.8%) | Renders: 30 (+0) | Paint: 1,317.93 ms +19.05 ms(+1.5%)
10 tests within noise — details Check out the code infra dashboard for more information about this PR. |
…into charts-warning-msgs
Improve warning message for missing series IDs in development mode. Signed-off-by: sai chand <60743144+sai6855@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds process.env.NODE_ENV !== 'production' guards around warnOnce calls in chart axis and radar axis components, so warning code can be stripped from production builds.
Changes:
- Guard
warnOnceinChartsXAxiswith NODE_ENV check. - Guard
warnOnceinChartsYAxiswith NODE_ENV check. - Guard
warnOnceinuseRadarAxiswith NODE_ENV check.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/x-charts/src/ChartsXAxis/ChartsXAxis.tsx | Wraps warning in dev-only env check |
| packages/x-charts/src/ChartsYAxis/ChartsYAxis.tsx | Wraps warning in dev-only env check |
| packages/x-charts/src/RadarChart/RadarAxis/useRadarAxis.ts | Wraps warning in dev-only env check |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| `MUI X Charts: Your radar axis tries to display values for the metric "${metric}" which does not exist.`, | ||
| `Either add this metric to your radar, or pick one from the existing metrics: ${existingMetrics.join(', ')}`, | ||
| ]); | ||
| if (process.env.NODE_ENV !== 'production') { |
There was a problem hiding this comment.
This condition should be on the previous if block to shorthand the entire block since we don't do/return anything from inside it
if (process.env.NODE_ENV !== 'production' && !existingMetrics.includes(metric)) {…into charts-warning-msgs
This PR adds environment checks to
warnOncecalls where they were previously missing.