警告:道具类型失败:提供给`j`的道具'children'无效

时间:2019-09-22 07:13:25

标签: javascript reactjs frontend react-proptypes

我收到此错误:

index.js:1375警告:道具类型失败:提供给children的道具j无效。

in j (at HomePage.jsx:15)
in HomePage (created by Context.Consumer)
in Route (at App.jsx:17)
in App (at src/index.js:13)
in Router (created by BrowserRouter)
in BrowserRouter (at src/index.js:12)

我在我的应用程序中使用了一个外部组件,该组件是从github获得的,可在后台渲染视频。这是链接。 https://github.com/samAbeywickrama/reactjs-videobg

这与原型有关,但是由于其继承性和react建议使用flo,因此我根本不使用类型检查。

import React from "react";
import {
Container,
Header,
Image,
Button,
Icon
} from "semantic-ui-react";
import VideoBg from 'reactjs-videobg';
import mp4 from '../../video/hack4.mp4';

const HomePage = ({history}) => {
 return (
  <div className='masthead'>
  <VideoBg loop={true}>
    <VideoBg.Source src={mp4} type='video/mp4' />
  </VideoBg>
    <Container text textAlign='center'>
      <Header as='h1' inverted>
        <Image
          size='massive'
          src='/assets/logo.png'
          alt='logo'
          style={{ marginBottom: 12 }}
        />
        CodeUp
      </Header>
      <Button onClick={() => history.push('/events')} size='huge' 
      inverted>
        Enter
        <Icon name='right arrow' inverted />
      </Button>
    </Container>
</div>
);
};

2 个答案:

答案 0 :(得分:1)

children是VideoBg组件中用于向其添加视频源的道具。

我在lib库中提出了一个问题,需要进一步调查

答案 1 :(得分:0)

这应该是评论,但为此需要更多的声誉...

我有时发现调试反应真的很棘手。您的代码中似乎没有所谓的j

我确实在此代码中看到一件事-不起作用,您需要text = {true} , see above

jsx标记属性实际上是jsx(Javascript)对象,因此无法处理类似text之类的东西。因此,您必须给它一个提示,它是一个布尔值

这可能是问题,也可能不是问题。...