简体   繁体   中英

Creating a calendar component with moment and react

I was searching for React Calendar component I found this fiddle however I am not understanding some part of code in that, below is the link

JSFiddle Link for calendar component code

I did not understand below part

monthRange.by('days', function(moment) {
  var ref;
  if (ref = moment.week(), indexOf.call(weeks, ref) < 0) {
    return weeks.push(moment.week());
  }
});

which lib is that ".by" using, I ve included moments, moment-range, react-with-addons, but the above method is returning weeks with length 0.

when I debug, I am not able to go into that method.

Don't reinvent the wheel, if you are looking for a ready solution use react-big-calendar . If you want to build a calendar as a part of a project to learn React look at a simpler code like holiday-calendar

你可以只使用react-big-calender ,我个人觉得这比创建你自己的要好得多。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM