【问题标题】:Issues with react-big-calenderreact-big-calendar 的问题
【发布时间】:2020-04-15 06:16:47
【问题描述】:

我第一次在 react 中使用日历,发现 react-big-calender 很有趣。我创建了包含一些事件的日历,但遇到了一些我不熟悉的控制台错误。

Warning: Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate 
bugs in your code. 

* Move data fetching code or side effects to componentDidUpdate. 
* If you're updating state whenever props change, refactor your code to use memoization techniques or 
  move it to static getDerivedStateFromProps.

Please update the following components: DayColumn, TimeGrid, TimeGutter

谁能给我解释一下?谢谢!

另外,我想知道是否可以只显示月视图而不是所有(日、周、议程)视图。

这是我的代码:

   render(){

    const localizer = momentLocalizer(moment)

    const holidays = []  

    this.state.holidays.map((holiday,index) => {

        let start = moment(holiday.for_date).toDate()
        holidays.push({ start: start, 
                        end: start, 
                        color: holiday.color, 
                        key:index, 
                        title:holiday.title})
        })

    const list = [...holidays]     

   return(
   <div className="calender">
     <Calendar
       localizer={localizer}
       events={list}
       defaultDate={moment().toDate()}
       startAccessor="start"
       endAccessor="end"
     />
  </div>
  )}

【问题讨论】:

    标签: html css reactjs calendar react-big-calendar


    【解决方案1】:

    简而言之,这意味着 NPM 包 Big Calendar 的维护者尚未更新他们的代码以移除已弃用的功能,特别是在此警告的情况下是 componentWillReceiveProps

    在您的应用中,您无能为力。

    看起来确实有一些进展,可以看到here

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 2022-11-07
      • 1970-01-01
      相关资源
      最近更新 更多