react-big-calendar component children not updating on state-update

放肆的年华 提交于 2019-12-13 03:48:54

问题


I have the following in my Calendar component JSX:

components={{
          dateCellWrapper: ({children, value}) => 
          React.cloneElement(Children.only(children), {
            style: {
              ...children.style,
              backgroundColor: calendarDest.map((x,i) => 
            moment(value).add('days', 1).isBetween(x.dtArrive,x.dtDepart)? 
             colors[i]: 'white'),
              opacity: .25
            },
        })
        }}

It is inside a stateless functional component. I have calendarDest, above, updating into the state via a useEffect hook that updates the state every time the props change.

The calendar component's state updates properly, but the children accessed in components={{...}} only ever reflect the initial state of the parent component.

来源:https://stackoverflow.com/questions/57697916/react-big-calendar-component-children-not-updating-on-state-update

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!