If no data is present (yet), the calendar component crashes with the following error:
Uncaught TypeError: Cannot read property 'value' of undefined
at nivo-calendar.js:510
at new WithPropsOnChange (withPropsOnChange.js:52)
[...][1]
This causes an issue if p.e. the component is still waiting for data to be loaded asynchronously. The error is caused by in /packages/nivo-calendar/src/enhance.js:
if (domain === 'auto') {
colorDomain = [minBy(data, 'value').value, maxBy(data, 'value').value]
}
If no data is given, minBy/maxBy will return undefined, and then .value is called on that. To prevent this from happening, _.get can be used, which will safely return undefined instead of throwing an error. I'll submit a pull request in a moment.
--
[1] Error message shortened for clarity. Full trace in attachment: nivo-calendar-error.txt
If no data is present (yet), the calendar component crashes with the following error:
This causes an issue if p.e. the component is still waiting for data to be loaded asynchronously. The error is caused by in
/packages/nivo-calendar/src/enhance.js:If no data is given, minBy/maxBy will return
undefined, and then.valueis called on that. To prevent this from happening,_.getcan be used, which will safely returnundefinedinstead of throwing an error. I'll submit a pull request in a moment.--
[1] Error message shortened for clarity. Full trace in attachment: nivo-calendar-error.txt