Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态设置日历列表高度_Javascript_React Native - Fatal编程技术网

Javascript 动态设置日历列表高度

Javascript 动态设置日历列表高度,javascript,react-native,Javascript,React Native,我想根据活动月份中天数的结构设置CalendarList组件的高度 我创建了一个函数来确定日历列表的正确高度 日历高度计算器(){ const currentmount=时刻(this.props.calendarStore.currentmount,“YYYY-MM”) 如果(currentMonth.startOf(“月”).weekday()==5&¤tMonth.daysInMonth()>30){ 返回340 } 如果(currentMonth.startOf(“月”).

我想根据活动月份中天数的结构设置CalendarList组件的高度

我创建了一个函数来确定日历列表的正确高度


日历高度计算器(){
const currentmount=时刻(this.props.calendarStore.currentmount,“YYYY-MM”)
如果(currentMonth.startOf(“月”).weekday()==5&¤tMonth.daysInMonth()>30){
返回340
}
如果(currentMonth.startOf(“月”).weekday()==6&¤tMonth.daysInMonth()>29){
返回340
}
返回300
}
CalendarList组件通过其height属性调用该函数


通过广泛使用
console.log
,我可以确认它在每次重新渲染时都会被调用,并返回正确的高度值。 但是,
CalendarList
仅对初始值作出反应,并忽略以下重新渲染


如何通过
calendarHeightCalculator
功能设置正确的高度

更改日历高度不会触发状态更改,因此日历不会重新渲染

如果要重新呈现日历,请更改在日历列表上实际设置状态的内容


查看组件以查看触发重新渲染的道具

重新渲染时高度不会改变