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. WF学习笔记(一)

    -流程启动方式1: WorkflowInvoker.Invoke(new Workflow1()); -流程启动方式2: WorkflowApplication instance = new Work ...

  2. Bootstrap_Javascript_弹窗

    一. 结构分析 Bootstrap框架中的模态弹出框,分别运用了“modal”.“modal-dialog”和“modal-content”样式,而弹出窗真正的内容都放置在“modal-content ...

  3. Sphinx 排序模式 SetSortMode

    可使用如下模式对搜索结果排序: SPH_SORT_RELEVANCE 模式, 按相关度降序排列(最好的匹配排在最前面) SPH_SORT_ATTR_DESC 模式, 按属性降序排列 (属性值越大的越是 ...

  4. 《C和指针》章节后编程练习解答参考——6.2

    <C和指针>——6.2 题目: 编写一个函数,删除源字符串中含有的子字符串部分. 函数原型: int del_substr(char *str, char const *substr); ...

  5. 为什么Tomcat的webapps目录下新建的目录不能访问html文件?

    在Tomcat安装目录中,webapps默认为部署网站用的目录.webapps/ROOT是网站的根目录,其它目录都是网站的子目录,如webapps\jsp-examples目录.但是,当我们新建一个子 ...

  6. 理解Javascript 的闭包(closure)

    要理解闭包的概念先从变量的作用域说去 一.变量的作用域 要理解闭包,首先必须理解Javascript特殊的变量作用域. 变量的作用域无非就是两种:全局变量和局部变量. Javascript语言的特殊之 ...

  7. python Hbase Thrift pycharm 及引入包

    cp -r hbase/ /usr/lib/python2.7/site-packages/ 官方示例子http://code.google.com/p/hbase-thrift/source/bro ...

  8. BZOJ 3196 二逼平衡树

    Description 您需要写一种数据结构(可参考题目标题),来维护一个有序数列,其中需要提供以下操作:1.查询k在区间内的排名2.查询区间内排名为k的值3.修改某一位值上的数值4.查询k在区间内的 ...

  9. linux 修改目录文件权限,目录文件所属用户,用户组

    1:查看命令:ll drwxr-xr-x  4 gamer ftp      4096 Mar  7 16:56 gstore drwxrwxrwx 10 root  ftp      4096 De ...

  10. ios入门之c语言篇——基本函数——5——素数判断

    参数返回值解析: 参数: m:int,需要判断的值: 返回值: 0:非素数 1:素数 函数解析: 注意:函数没有对输入进行判断,请自己屏蔽非法输入 int prime(int m) { int tem ...