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.

How can I use multiple values array?

See original GitHub issue

i can’t use value more than 2 value of array

<Calendar
   onClickDay={value => alert('Clicked day: ', value)}
   value={[new Date(), new Date().setDate(12)]}
/>

it work but if value is [new Date(), new Date().setDate(12) , new Date().setDate(14)] error invalid date

and How can i custome style of value active

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
tquirogacommented, Apr 9, 2018

If you just need to highlight dates in the calendar, a workaround is to use tileClassName with the function: ({ date, view }) => // check if the date is in your array here and return className accordingly... And then style it as you wish.

1reaction
orhan-swecommented, Jun 4, 2018

@tquiroga This is a good solution but to get it to work one must first inject an array with the first and last date of the month to the “value” prop (if one wants to be able to highlight any date of the month). But as this will set all dates as active one must then set them all as inactive by overriding .react-calendar__tile–active. The solution below is for a problem of type “when hovering over some area some calendar dates should be highlighted”:

<ReactCalendar
    key={index}
    activeStartDate={moment().subtract((clusterPatternDays.length - 1) - index, 'months').startOf('month').toDate()}
    tileClassName={({date, view}) => {
        if(view === 'month' && highlighted && (dates || []).includes(date.toDateString())) 
            return classNames({[`calendar-${highlighted}`]: highlighted});
        else {
            //we must override the active class otherwise everything will show as selected all the time
                return "react-calendar__tile--inactive";
        }
    }}
//for the dates to be highlighted we must inject all dates for the month to value prop
    value={[ 
        moment().subtract((clusterPatternDays.length - 1) - index, 'months').startOf('month').toDate(),
        moment().subtract((clusterPatternDays.length - 1) - index, 'months').endOf('month').toDate()
 ]}
/>

This does work but if there is a better solution I would like to know.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Java array with multiple values - Stack Overflow
Use a simple array (or List) of objects: ... Store your value using setter and getter method and save object into list List<TestObject>...
Read more >
Arrays — store multiple items using the same variable. - Medium
If variables are like boxes, arrays are like lockers. Every locker in the same compartment store similar items. Each locker can be identified ......
Read more >
Array in Java: store multiple values in a single variable
Array in Java is used to store multiple values in a single variable consisting of the same data type and can be retrieved...
Read more >
Insert multiple values into an array in JavaScript | Techie Delight
Insert multiple values into an array in JavaScript · 1. Using ES6 Spread operator with slicing · 2. Using Array.prototype.splice() function · 3....
Read more >
Push multiple Values to an Array in JavaScript | bobbyhadz
Use the Array.push() method to push multiple values to an array, e.g. arr.push('b', 'c', 'd'); . The push() method adds one or more...
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