[英]TypeError: Cannot read property 'props' of undefined react
I am new to react js and following react code giving me this error我是反应 js 的新手,并遵循反应代码给我这个错误
"TypeError: Cannot read property 'props' of undefined at Button (D:\\my-app.next\\server\\static\\PqudrDXAzXfiQCJ2zK-7F\\pages\\index.js:408:59)." “类型错误:无法读取按钮处未定义的属性‘道具’(D:\\my-app.next\\server\\static\\PqudrDXAzXfiQCJ2zK-7F\\pages\\index.js:408:59)。”
please assist me to solve this, thank you.请帮我解决这个问题,谢谢。
here is my index.js这是我的 index.js
import React, { Component } from 'react';
import Link from 'next/link';
import Head from '../components/head';
import Nav from '../components/nav';
import Button from '../components/Button';
export default () => (
<div>
<Head title="Home" />
<Nav />
<Button text="Demo Button" />
</div>
);
and here is my Button.js file这是我的 Button.js 文件
import React from 'react';
import './button.css';
import { string } from 'prop-types';
const Button = (props) => (
<button>{ props.text } </button>
);
Button.propTypes = {
text: string
};
export default Button;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.