Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

add check for data length #195

Merged
merged 2 commits into from
Feb 6, 2017
Merged

add check for data length #195

merged 2 commits into from
Feb 6, 2017

Conversation

boygirl
Copy link
Contributor

@boygirl boygirl commented Feb 5, 2017

@@ -81,7 +81,8 @@ export default class Bar extends React.Component {
getBarWidth(props, style) {
const {width, data} = props;
const padding = props.padding.left || props.padding;
const defaultWidth = data.length === 0 ? 8 : (width - 2 * padding) / data.length;
const length = Array.isArray(data) ? data.length : 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'd take a little more digging, but it might be better if we figure out where the possibility of null data is coming from. We already have a Data module that returns an array of data, empty or not - if we find the source of null here and enforce the same constraints on it, we won't have to do these type checks internally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@DerekMaffett the null data is coming back when users return null from an event mutation. My guess is that because we are using _.defaults to combine baseProps with event state, so undefined is being handled correctly, but null is not. That said, this error was not showing up when returning null prior to my changes related to shouldComponentUpdate in the primitive components, and the change is also not showing up in shared events. My guess for a systematic fix would be to add null checking to add-events.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found it!

@boygirl
Copy link
Contributor Author

boygirl commented Feb 6, 2017

@DerekMaffett thanks for pressing me on that.

@boygirl boygirl merged commit adba9b8 into master Feb 6, 2017
@boygirl boygirl deleted the fix-bar-width-bug branch February 6, 2017 05:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How to clear previous styles after an event
2 participants