元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:数字

时间:2020-08-18 09:00:01

标签: reactjs react-native

本机。我正在尝试使用react-native-video显示视频,但是出现以下错误

错误:元素类型无效:预期为字符串(对于内置 组件)或类/函数(用于复合组件),但得到: 数字。

检查VideoAndroid的呈现方法。

我没有得到这个错误是什么?谁能帮我。

提前谢谢

这是代码段

    // all imports

import React, { useState, useEffect } from 'react'
import { Image, StyleSheet, Text, Dimensions, TouchableWithoutFeedback, TouchableOpacity , View, StatusBar } from 'react-native'
import Video, {
  OnSeekData,
  OnLoadData,
  OnProgressData,
} from 'react-native-video';
import VideoPlayer from 'react-native-video-controls';
import Orientation from 'react-native-orientation-locker';
import { FullscreenClose, FullscreenOpen } from '../../assets/icons';

        interface State {
          fullscreen: boolean;
          play: boolean;
          currentTime: number;
          duration: number;
          showControls: boolean;
        }
        
        const VideoAndroid = () => {
        
        
          const videoRef = React.createRef<Video>();
          const [state, setState] = useState<State>({
            fullscreen: false,
            play: false,
            currentTime: 0,
            duration: 0,
            showControls: true,
          });
        
           return( 
        
            <>
         <View style={styles.container}>
                    <TouchableWithoutFeedback onPress={showControls}>
                      <View>
                        <Video
                          ref={videoRef}
                          source={{
                            uri:
                              'http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4',
                          }}
                          style={state.fullscreen ? styles.fullscreenVideo : styles.video}
                          controls={false}
                          resizeMode="contain"
                          onLoad={onLoadEnd}
                          onProgress={onProgress}
                          onEnd={onEnd}
                          paused={!state.play}
                        />
                        {state.showControls && (
                          <View style={styles.controlOverlay}>
                            <TouchableOpacity
                              onPress={handleFullscreen}
                              hitSlop={{ top: 10, bottom: 10, left: 10, right: 10 }}
                              style={styles.fullscreenButton}>
                              {state.fullscreen ? <FullscreenClose /> : <FullscreenOpen />}
                            </TouchableOpacity>
                          </View>
                        )}
                      </View>
                    </TouchableWithoutFeedback>
            
                  </View>
        
            </>  
        )
           
        }

0 个答案:

没有答案