父组件
import React from 'react';
import Prop from "../../compontes/Prop/Prop.jsx"
export default class Gszc extends React.Component {
constructor(props) {
super(props)
this.state = {
title:'你在干什么'
}
}
render() {
return <div>
<h1>父往子传值</h1>
<Prop name={this.state.title}></Prop>
</div>
}
}
子组件
import React from 'react';
export default function prop(props) {
return <div>
<p>我是子组件</p>
<h1>{props.name}</h1>
</div>
}