From 5ac42141d2495aa1b4afc22e6e2ada3e7b7e9a51 Mon Sep 17 00:00:00 2001 From: Maurice Spiewack <15855093+mdorr@users.noreply.github.com> Date: Thu, 19 Jul 2018 07:52:04 -0400 Subject: [PATCH] fix(calendar): fix crash when no data is empty * Fix error when no data is available * Check for data array length * Run formatter and linter --- packages/nivo-calendar/src/enhance.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/nivo-calendar/src/enhance.js b/packages/nivo-calendar/src/enhance.js index 86b58c67d..005e125b4 100644 --- a/packages/nivo-calendar/src/enhance.js +++ b/packages/nivo-calendar/src/enhance.js @@ -24,7 +24,11 @@ export default Component => withPropsOnChange(['data', 'domain', 'colors'], ({ data, domain, colors }) => { let colorDomain if (domain === 'auto') { - colorDomain = [minBy(data, 'value').value, maxBy(data, 'value').value] + if (data.length === 0) { + colorDomain = [0, 0] + } else { + colorDomain = [minBy(data, 'value').value, maxBy(data, 'value').value] + } } else { colorDomain = [...domain] }