React Native使用Video组件时出现“cannot read property of 'getViewManagerConfig' of null”错误求助
React Native使用Video组件时出现“cannot read property of 'getViewManagerConfig' of null”错误求助
大家好,我在React Native项目中使用Video组件时碰到了一个困扰很久的错误,报错内容为cannot read property of 'getViewManagerConfig' of null。以下是我的相关代码和问题细节,希望能得到大家的帮助:
Data是一个URL数组,maxResults是一个整数:
function VideoScreenWrapper({data, maxResults}){ const videoRef = useRef([]); const onError = (error) => { console.log("Error: ", error); } console.log("Data in VideoScreenWrapper: ", data); if (data && data.length>0){ return( <View> {data.slice(0, maxResults).map((item, index) => ( <Video key={index} source={{ uri: item }} ref={el => videoRef.current[index] = el} onError={onError} //style={styles.backgroundVideo} resizeMode='cover' controls /> ))} </View> ); }else { return( <View> <Text> No data </Text> </View> ); } }
错误栈截图如下:
我已经尝试过这些方法,但都没能解决问题:
- 修改
useRef的使用方式 - 打印错误信息排查问题
- 更换不同的Video组件库
备注:内容来源于stack exchange,提问作者Shayan Shamsipour
相关产品推荐
相关产品推荐

