问题描述
因此,我使用onLayout来获取容器高度:
const { width,height } = Dimensions.get("window");
const [timeHeight,setTimeHeight] = useState(height);
const TIME_HEIGHT = timeHeight;
<View
onLayout={({
nativeEvent: {
layout: { height: h },},}) => setTimeHeight(h)}
>
<Text style={styles.text}> {item} </Text>
</View>
但是,当我第一次进入程序时,TIME_HEIGHT变量等于屏幕高度,因此,它等于钩子的默认值。进入该功能之前是否可以测量容器的高度?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)