我有一个视频组件和EnterFullScreen函数,带有更改屏幕方向的逻辑,我想在更改屏幕方向后重新呈现视频组件,因为它在样式中有一个宽度属性.我试着使用Use-force-UPDATE和Change State,但没有帮助.
const {width, height} = Dimensions.get('window')
async function enterFullscreen() {
if (!isFullscreen) {
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.LANDSCAPE)
// re-render here
}
else {
await ScreenOrientation.lockAsync(ScreenOrientation.OrientationLock.PORTRAIT_UP)
// re-render here
}
}
video: {
width: width,
height: height,
zIndex: 1
},
import { Video, ResizeMode } from 'expo-av';
<Video
ref={video}
style={styles.video}
source={source}
resizeMode={ResizeMode.CONTAIN}
onReadyForDisplay={getDurationMillis}
onPlaybackStatusUpdate={getPositionMillis}
onLoad={() => {setIsLoading(false)}}
/>
如果我进入全屏模式后按CTRL+S,视频有合适的宽度,如果我没有,它就像第二个截图 如何重新呈现我的组件?