我正在尝试与子组件通信,但只关注html 元素中的onChange事件<input>。谁能向我解释为什么这两个组件似乎没有通信,以及为什么子组件中的 console.log 没有显示?
家长
import React from 'react';
import FileUpload from './FileUpload'
class App extends React.Component {
callChild = ()=>{
return (
<FileUpload displayOnUpload = {this.displayOnUpload} test = 'passed succesfully'/>
)
}
render(){
return (
<div>
<input
type="file"
id = "my-file"
multiple
onChange = {()=>this.callChild()}
/>
</div>
)
}
}
export default App
孩子
const FileUpload = (props)=> {
console.log(props.test)
return (
<div>
hi
</div>
)
}
export default FileUpload
MMTTMM
慕雪6442864
相关分类