【发布时间】: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