question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

value always 'null'

See original GitHub issue

<CalendarHeatmap endDate = {new Date(endCalendar)} numDays = {365} values = {schedulesTimes} onClick = {(value) => { alert(value) }} titleForValue = {customTitleForValue} tooltipDataAttrs = {customTooltipDataAttrs} /> image

when i click the block, it always alert null, have any idea? 😊

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
kevinsqicommented, Sep 7, 2016

yeah - so the value prop, schedulesTimes, is an array of objects, right? the component expects a value attribute for each object which contains the date. The onClick callback gets passed the value attribute of that particular day - so if you don’t have an object for that day, value will be null.

Currently, if you want to get a non-null value for every square, you’ll have to add all the days in the range to the values prop in order to have onClick get the right value, e.g.:

<CalendarHeatmap
  values={[
    { value: <startDate>},
    { value: <startDate + 1>},
    ...
    { value: <endDate> }
  ]}
/>

I was considering adding a second parameter to onClick to provide the date clicked even if value wasn’t provided, so that the values array can be sparse in this use case, but wasn’t sure it was worth making the API more complicated. I’m open to that idea.

0reactions
lucaschencommented, Jan 11, 2019

I don’t think that adding a second argument is a bad idea.

Right now the API provides no way for the code to detect which empty square was clicked, when an empty square is clicked.

I can definitely see a second argument in the onClick handler being extremely useful, e.g. when trying to add new information for a particular date.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java value is always null? [duplicate] - Stack Overflow
I have a value in Java that is always null but I don't understand why, because I am setting the value of the...
Read more >
Code Inspection: Expression is always 'null' - PhpStorm
Code Inspection: Expression is always 'null'​​ Reports the variables in return statements that are always null . In the following example, the $ ......
Read more >
Value always null | Blazor Forums - Syncfusion
</SfAutoComplete>. This is my current setup but the value is always Null whatever I select. Also how do I set the initial selected...
Read more >
Why is value always null when using Sitecore Forms with a ...
I'm using a custom validator for ReCaptcha on Sitecore forms . I've followed all of the instructions in the Sitecore docs for creating...
Read more >
SQL NULL Values - IS NULL and IS NOT NULL - W3Schools
A field with a NULL value is a field with no value. If a field in a table is optional, it is possible...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found