当前第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中如何引用json
怎么查看React源码
React grommet是什么
混合开发可以用React吗
浅谈React中获取数据的方法及其优缺点
React中怎么获取数据
React中如何优雅的使用svg
React组件几种声明方式是什么
React组件树是什么
bootstrap和React区别
更多相关阅读请进入《React》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » react子向父通信有哪些方法?