码迷,mamicode.com
首页 > Web开发 > 详细

Reactjs学习 -- factory、component和element

时间:2015-01-15 14:21:15      阅读:932      评论:0      收藏:0      [点我收藏+]

标签:framework   web前端   reactjs   

在使用reactjs的时候,我们经常会使用到下面三个方法:

  1. React.createFactory()
  2. React.createClass()
  3. React.cleateElement()
这三个方法接受的参数和返回的对象类型是不同的。

React.createFactory

该方法会接受一个component类型的对象,并且返回一个factory方法。使用返回的factory可以创建element。如

<span style="font-size:12px;">var factory = React.createFactory(component);
var element = factory(props, ...., children);</span>


React.createClass

该方法会返回一个component。


React.cleateElement

返回一个element

如果实例化的时候没有按照对应的类型来调用,React会抛出一个warning,据说下一个版本会抛出一个error。


ps: 
我写了一个project seed,框架使用了Backbone + React + requirejs, UI框架使用了semantic UI,能翻墙的小伙伴可以参考一下。
https://github.com/gaoyuan-mountain/framework-project-seed/tree/master/react-backbone

待完善...

Reactjs学习 -- factory、component和element

标签:framework   web前端   reactjs   

原文地址:http://blog.csdn.net/duran1986/article/details/42740025

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!