/* eslint-disable @typescript-eslint/no-unused-vars */
import React, { useState } from 'react';
const Fater = () => {
const [title, setTitle] = useState<string>('第一个标题')
const changeTitle = (title: string) => {
setTitle(title)
}
return(
<>
<Child title={ title } changeTitle={ changeTitle }/>
</>
)
}
const Child = (props: any) => {
const { changeTitle, title } = props;
return(
<>
<h1>{ title }</h1>
<button onClick={ () => { changeTitle('第二个标题') } }>
更改标题
</button>
</>
)
}