当前第2页 返回上一页
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | import React, { Component } from 'react' ;
import List3 from './components/List3' ;
export default class App extends Component {
constructor(...args) {
super (...args);
this .state = {
isShowList3: false ,
};
}
showConponent = () => {
this .setState({
isShowList3: true ,
});
}
hideConponent = () => {
this .setState({
isShowList3: false ,
});
}
render() {
return (
<div>
<button onClick={ this .showConponent}>显示Lists组件</button>
{
this .state.isShowList3 ?<List3 hideConponent={ this .hideConponent} />: null
}
</div>
);
}
}
|
观察一下实现方法,可以发现它与传统回调函数的实现方法一样.而且setState一般与回调函数均会成对出现,因为回调函数即是转换内部状态是的函数传统;
更多编程相关知识,请访问:编程学习!!
以上就是react子向父通信有哪些方法?的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
React中什么叫子组件
React向数组中追加数据的方法
安装React脚手架失败怎么办
React中swiper插件如何使用?
web前端React是什么?
手把手教你如何使用vite+React进行组件开发(实践)
angular与angularjs、React和vue的简单对比
vue和React有什么相似点
在React官网如何下载React.js
React有哪几种传递参数的方式
更多相关阅读请进入《React》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » react子向父通信有哪些方法?