如何在 react-big-calendar 单元格中显示 text/button?

How to display text/button in react-big-calendar cell?

我能够通过 slotPropGetter 道具编辑周视图插槽样式,但找不到如何在没有事件时将文本传递到插槽的解决方案。图片上的例子。

当前 table:

<BigCalendar
  selectable
  className="calendar"
  popup
  localizer={localizer}
  formats={formats}
  events={this.state.events}
  defaultView={BigCalendar.Views.WEEK}
  views={['week']}
  step={90}
  timeslots={1}
  min={new Date(2019, 0, 1, 8, 0)} // 8.00 AM
  max={new Date(2020, 0, 1, 22, 0)} // Max will be 6.00 PM!
  onSelectEvent={event => this.showModalHandler(event, false, true)}
  onSelectSlot={event => this.showModalHandler(event, true, false)}
  eventPropGetter={this.eventStyleHandler}
  slotPropGetter={this.slotStyleHandler}
  components={{
      event: this.CustomEvent,
      week: {
          header: CustomDateHeader,
      },
  }}

/>

或许可以使用 timeSlotWrapper?以某种方式更改 timeSlopWrapperProps.children?

中的内容
const timeSlotWrapper = timeSlotWrapperProps => {
    return timeSlotWrapperProps.children
}

要玩的沙盒:https://codesandbox.io/embed/react-big-calendar-example-s6lsl?fontsize=14&hidenavigation=1&theme=dark

React 大日历 api 文档:http://jquense.github.io/react-big-calendar/examples/index.html#api

解决方案是为每个单元格创建事件并修改事件样式,而不是尝试修改空单元格样式。

  <-- use this style -->
    export const useStyles = makeStyles((theme) => ({
      dateCell: {
        borderRight: "0.5px solid #DDDDDD",
        flex: "1 1 0%",
        display: "flex",
        justifyContent: "flex-end",
        bottom: 0,
      },
      positon: {
        position: "absolute",
        bottom: 0,
        padding: "0px",
        zIndex: 9999999,
      },
    }));
    
    
     const eventWrapper = ({ value }) => {
        return (
          <div className={`${classes.dateCell}`}>
            <IconButton
              onClick={() => schedulePost(value)}
              className={classes.positon}
            >
              <AddCircleOutlineIcon fontSize="small" />
            </IconButton>
          </div>
        );
      };
    
     <Calendar
            localizer={localizer}
            events={state}
            startAccessor="start"
            endAccessor="end"
            defaultDate={new Date()}        
            components={{         
              dateCellWrapper: eventWrapper`enter code here`,
            }}
            eventPropGetter={customeEventPropogatter}
          />