Skip to content

Commit

Permalink
Clean up multiple warning logs and fix regression on children compone…
Browse files Browse the repository at this point in the history
…nts not getting their defaultProps (#64)
  • Loading branch information
Kris Salvador authored May 9, 2018
1 parent 3d4d571 commit 7e8e94b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/utils/resolveXYScales.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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 };
}

Expand Down

0 comments on commit 7e8e94b

Please sign in to comment.