We are going to ensure our app is structured in a clear way using functional components. Then, we are going to pass those components state values from the parent class component.

const { Component } = React;

const InputField = (props) => {
return (
<input type="text" />
)
} const Button = (props) => {
return (
<button>Go</button>
)
} const List = (props) => {
console.log(props)
return (
<ul>
{props.todos.map(todo => {
return <li key={todo.id}>{todo.name}</li>
})}
</ul>
)
} class App extends Component {
constructor() {
super()
this.state = {
todos: [
{id: 0, name: 'foo'},
{id: 1, name: 'bar'},
{id: 2, name: 'baz'}
]
}
} render() {
return (
<div className="App">
<InputField />
<Button />
<List todos={this.state.todos} />
</div>
)
}
} ReactDOM.render(
<App />,
document.getElementById('root')
);

最新文章

  1. ttf,eot,woff,svg,字体格式介绍及使用方法
  2. 用Eclipse搭建ssh框架
  3. Android UI性能优化实战, 识别View中的性能问题
  4. 今天执行grep命令差点把服务器搞崩
  5. AJAX-----04XMLHttpRequest对象的ajax
  6. c#之Redis实践list,hashtable
  7. hdu 3280 动态规划
  8. .Net Core 中的包、元包与框架(Packages, Metapackages and Frameworks)
  9. gridControl 中CellValueChanged,ShowingEditor,CustomDrawCell的用法
  10. SSM-SpringMVC-33:SpringMVC中拦截器Interceptor讲解
  11. app与手机其他软件交互测试
  12. 应用 memcached 提升站点性能
  13. Java静态方法为什么不能访问非静态方法
  14. PowerDesigner 12.5 汉化包-CSDN下载
  15. OpenGL 画出雷达动态扫描效果(二) 非底图
  16. poj 2599 单调栈 ***
  17. ReactNative——UI1.登录界面样式设置
  18. HBase数据访问的一些常用方式
  19. fortran打开文件“” /dde错误
  20. node express+mysql搭建简易API服务—body-parser中间件

热门文章

  1. ftp实现图片上传,文件也类似
  2. yarn的安装和使用
  3. JS 数字格式千分位相互转换
  4. 学习笔记:Vue——插槽
  5. 三期_day03_环境搭建和客户页面_I
  6. 基于ContentObserver来动态取消或加入屏幕超时任务
  7. amazeui学习笔记--css(常用组件10)--导航条Topbar
  8. iOS开发 非常全的三方库、插件、大牛博客等等
  9. C# 进制转换 在什么情况下使用16进制,字节数组,字符串
  10. 关于 /etc/zabbix/zabbix_agentd.conf 文件 Hostname 文件的说明