The application will dislay a some catalogs, and each catalog has title image, description.

Catalog:

import React from 'react';
import AppStore from '../stores/app-store';
import CatalogItem from './app-catalogitem'; function getCatalog(){
return { items: AppStore.getCatalog() }
} class Catalog extends React.Component {
constructor(){
super();
this.state = getCatalog()
}
render(){
let items = this.state.items.map( item => {
return <CatalogItem key={ item.id } item={ item } />
});
return (
<div className="row">
{ items }
</div>
)
}
}
export default Catalog;

Each Catalog render CatalogItem:

import React from 'react';
import AppActions from '../actions/app-actions';
import CartButton from './app-cart-button'; export default (props) => {
return (
<div className="col-xs-6 col-sm-4 col-md-3">
<h4>{ props.item.title }</h4>
<img src="http://placehold.it/250x250" width="100%" className="img-responsive"/>
<p>{ props.item.summary }</p>
<p>${ props.item.cost }</p>
<CartButton
handler={
AppActions.addItem.bind(null, props.item)
}
txt="Add To Cart"
/>
</div>
)
}

CartButton handle the click event whcih passed in:

import React from 'react';

export default (props) => {
return (
<button
className="btn btn-default btn-sm"
onClick={ props.handler }>
{ props.txt }
</button>
)
}

[Flux] Component / Views的更多相关文章

  1. Photon自定义加载Resource之外的资源

    PhotonNetwork.cs 结尾添加如下代码: #region >>> Photon自定义异步加载GameObject public delegate void CustomL ...

  2. [译] 关于 Angular 依赖注入你需要知道的

    如果你之前没有深入了解 Angular 依赖注入系统,那你现在可能认为 Angular 程序内的根注入器包含所有合并的服务提供商,每一个组件都有它自己的注入器,延迟加载模块有它自己的注入器. 但是,仅 ...

  3. 桌面应用开发之WPF页面导航

    先看效果图 Get Start   为了项目解耦,使用mvvmlight框架.MVVM设计模式请自行了解. 1 新建项目   新建一个MvvmLight(WPF)项目,删除其中无关文件夹:Design ...

  4. java的图形界面初学惯用

    1.单一界面的创建 public void mainFrame() { HashMap<String, Component> views = new HashMap<String, ...

  5. WPF MvvmLight简单实例(1) 页面导航

    原文:WPF MvvmLight简单实例(1) 页面导航 实现了那些功能,先看看截图: 操作描述: 在程序运行后,点击“Load”按钮,页面会加载PageOne,点击PageOne页面中的“Next” ...

  6. 浅入深出Vue:自动化路由

    在软件开发的过程中,"自动化"这个词出现的频率是比较高的.自动化测试,自动化数据映射以及各式的代码生成器.这些词语的背后,也说明了在软件开发的过程中,对于那些重复.千篇一律的事情. ...

  7. [codeigniter4]Upgrading from 3.x to 4.x

    CodeIgniter 4 is a rewrite of the framework, and is not backwards compatible. It is more appropriate ...

  8. 国产深度学习框架mindspore-1.3.0 gpu版本无法进行源码编译

    官网地址: https://www.mindspore.cn/install 所有依赖环境 进行sudo make install 安装,最终报错: 错误记录信息: cat     /tmp/mind ...

  9. [Vue warn]: Unknown custom element: <sapn> - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ---> <Evaluate> at src/views/index/

    关于vue报错: [Vue warn]: Unknown custom element: <sapn> - did you register the component correctly ...

随机推荐

  1. 不使用ASP.NET服务器端控件(包括form表单不加runat="server")来触发.cs里的事件(方法),(适用于有代码洁癖者)。

    很多时候,我们使用服务器端控件写出的代码,会给我们生成一些很多我们看不懂的代码(初学者),但是有时候我们并不需要这些代码(业务需求不同),对于生成的一些代码感到多余.所以我就开始想,有没有一种可能:不 ...

  2. POJ1611-The Suspects-ACM

    The Suspects Time Limit: 1000MS   Memory Limit: 20000K Total Submissions: 23002   Accepted: 11171 De ...

  3. Form表单三种提交按钮的区别?

    1.<input type='button' id='btn' onclick='check()' value="提交"> 说明:只是普通的按钮(不附带提交功能),不会 ...

  4. PHP: 使用CURL访问FTP

    今天要做FTP上传.本想用PHP自带的FTP函数来实现,结果发现这个模块没有编译进来,重新编译PHP太麻烦,改用其他方式实现吧  FTP上传 if (isset($_POST['Submit'])) ...

  5. arm-none-eabi-gcc install

    Zephyr除了官方的编译工具,还有第三方工具 arm-none-eabi-gcc . This PPA is an alternative to toolchain released at http ...

  6. Web.config总结

    %windir%/Microsoft.NET/Framework/v2.0.50727/CONFIG目录下machine.config定义了针对当前机器的WinForm程序和asp.net应用程序的配 ...

  7. BZOJ 1021 循环的债务

    Description Alice.Bob和Cynthia总是为他们之间混乱的债务而烦恼,终于有一天,他们决定坐下来一起解决这个问题.不过,鉴别钞票的真伪是一件很麻烦的事情,于是他们决定要在清还债务的 ...

  8. Cylinder

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2374 思路:三分枚举. #include &l ...

  9. cf C On Number of Decompositions into Multipliers

    题意:给你n个数,然后把这个n个数的乘积化成n个数相乘,可以化成多少个. 思路:分解质因数,求出每一个质因子的个数,然后用组合数学中隔板法把这些质因子分成n分,答案就是所有质因子划分成n份的情况的乘积 ...

  10. Apache HTTPServer与JBoss/Tomcat的整合与请求分发

    http://www.blogjava.net/supercrsky/archive/2008/12/24/248143.html