From 53f7e69d6321ee61854ff8d75e23e258758d4966 Mon Sep 17 00:00:00 2001 From: Kris Salvador Date: Wed, 9 May 2018 12:47:56 -0400 Subject: [PATCH] Clean up multiple warning logs and fix regression on children components not getting their defaultProps (#64) --- src/utils/resolveXYScales.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/utils/resolveXYScales.js b/src/utils/resolveXYScales.js index 98f49068..d8841fc6 100644 --- a/src/utils/resolveXYScales.js +++ b/src/utils/resolveXYScales.js @@ -127,6 +127,7 @@ export default function resolveXYScales(ComposedComponent) { static getSpacing = ComposedComponent.getSpacing; static getDomain = ComposedComponent.getDomain; static getMargin = ComposedComponent.getMargin; + static defaultProps = ComposedComponent.defaultProps; _resolveScaleType(props, Component) { let { xScaleType, yScaleType } = props; @@ -318,11 +319,7 @@ export default function resolveXYScales(ComposedComponent) { } } - if (!isDone()) { - console.warn( - `resolveXYScales was unable to resolve both domains. xDomain: ${xDomain}, yDomain: ${yDomain}` - ); - } else { + if (isDone()) { if (includeXZero && !_.inRange(0, ...xDomain)) { // If both are negative set max of domain to 0 if (xDomain[0] < 0 && xDomain[1] < 0) { @@ -342,6 +339,13 @@ export default function resolveXYScales(ComposedComponent) { } } + // TODO handle resolveXYScales not calculating the domain + // Because this is recursive on its children it will log this warn for children missing domain + // even though it is later inferred by parent later during the recursion + // if (!isDone()) { + // console.warn(`resolveXYScales was unable to resolve both domains. xDomain: ${xDomain}, yDomain: ${yDomain}`); + // } + return { xDomain, yDomain }; }