笔记,具体可以看看这个博客:

https://segmentfault.com/a/1190000004168886?utm_source=tag-newest

react 的jsx  document.createElement()一层层cereateElement

问题一:jsx render函数原理?

一:
引入:
react.js
react-dom.js
browser.min.js <script type="text/babel">
var destination = document.querySelector("#container"))
ReactDOM.render(
<div>hello world</div>
,destination
)
</script> 二,创建组件,React.createClass({ render:function()
{
return (
<div>hello world</div> ) } }) 三:组件的传递只能是父传给亲儿子,不能越级直接传孙子;{...this.props} <p color={this.props.color} size={this.props.size}></p>
等同于:
<p {...this.props}></p> 四:原生接口
getInitialState:function(){
//刷api接口的时候,组件还未渲染
return {
strikes:,
}
}
与this.state.strikes是返回的一个对象。 componentDidMount:function(){
//组件渲染完成,render渲染之前 } this.setState({strikes:this.state.strikes+}) 五:样式设计
render:function(){
var countStytle={
color:this.props.color,
fontSize:"14px",
padding:"10px",
backgroundColor:"#EEE" }
return (
<div className="letter" style={countStyle}>hello world</div>
)
} 六:react组件的生命周期 componentWillMount componentDidMount componentWillUnmount componentWillUpdate componentDidUpdate shouldComponentUpdate componentWillReceiveProps 组件接口:
顺序: getDefaultProps:function(){
//组件加载前被调用
//返回的是this.props
} getInitialSate:function(){
//返回的是this.state
} componentWillMount:function(){
//挂载到指定节点之前,会先调用这个函数
} render:function(){
return ()
} componentDidMount:function(){
//组件已经成功滴被浏览器加载了
} ======当setState()后,组件状态对象改变。=========
=====周期顺序===============
shouldComponentUpdate:function(newProps,newState){
//返回true,render
//返回false,不会render,界面不会改变
if(newState.count<){
return true
}else{
return false
}
} componentWillUpdate:function(){
//
rerurn;
} render:function(){
//
} componentDidUpdate:function(){
//
} React组件的生命周期机制:
componentWillUnmount
//节点销毁,从dom拿掉 用到调用Dom的api,把这个组件消亡掉:
ReactDOM.unmountComponentAtNode(destination) =====================
组件属性更改:调用顺序: componentWillReceiveProps:function(newProps){
//当组件的属性一旦更改,调用这个方法
return {};
} shuouldComponentUpdate:function(newProps,newState){
//
} componentWillUpdate render 绘制完成。 componentDidUpdate

略。

React组件,React和生命周期的更多相关文章

  1. 《React Native 精解与实战》书籍连载「React Native 中的生命周期」

    此文是我的出版书籍<React Native 精解与实战>连载分享,此书由机械工业出版社出版,书中详解了 React Native 框架底层原理.React Native 组件布局.组件与 ...

  2. React Native 中 component 生命周期

    React Native 中 component 生命周期 转自 csdn 子墨博客  http://blog.csdn.net/ElinaVampire/article/details/518136 ...

  3. react实战 系列 —— React 的数据流和生命周期

    其他章节请看: react实战 系列 数据流和生命周期 如何处理 React 中的数据,组件之间如何通信,数据在 React 中如何流动? 常用的 React 生命周期方法以及开源项目 spug 中使 ...

  4. Android四大基本组件介绍与生命周期

    Android四大基本组件介绍与生命周期 Android四大基本组件分别是Activity,Service服务,Content Provider内容提供者,BroadcastReceiver广播接收器 ...

  5. vue生命周期及使用 && 单文件组件下的生命周期

    生命周期钩子 这篇文章主要记录与生命周期相关的问题. 之前,我们讲到过生命周期,如下所示: 根据图示我们很容易理解vue的生命周期: js执行到new Vue() 后,即进入vue的beforeCre ...

  6. Django组件---Django请求生命周期和中间件

    Django组件---Django请求生命周期和中间件 Django请求生命周期 说明: client代表浏览器,浏览器的内部为我们封装了socket,Django的WSGI模块也为我们封装了sock ...

  7. React Native 学习-组件说明和生命周期

    组件的详细说明(Component Specifications) 当通过调用 React.createClass() 来创建组件的时候,你应该提供一个包含 render 方法的对象,并且也可以包含其 ...

  8. react系列(一)JSX语法、组件概念、生命周期介绍

    JSX React中,推出了一种新的语法取名为JSX,它给了JS中写HTML标签的能力,不需要加引号.JSX的语法看起来是一种模板,然而它在编译以后,会转成JS语法,只是书写过程中的语法糖. JSX的 ...

  9. 前端笔记之React(四)生命周期&Virtual DOM和Diff算法&日历组件开发

    一.React生命周期 一个组件从出生到消亡,在各个阶段React提供给我们调用的接口,就是生命周期. 生命周期这个东西,必须有项目,才知道他们干嘛的. 1.1 Mouting阶段[装载过程] 这个阶 ...

  10. React(v16.8.4)生命周期详解

    当前版本v16.8.4 装载过程(组件第一次在DOM树中渲染的过程): constructor(常用) -> getInitialState(v16.0已废弃) -> getDefault ...

随机推荐

  1. FtpWebRequest UploadFile返回"The underlying connection was closed: The server committed a protocol violation."解决方法

    将FtpWebRequest的KeepAlive设置为true. return Return<Boolean>( new Uri(ftpPath + fileName), request ...

  2. Unity3D笔记 英保通四 虚拟轴应用及键盘事件

    Input: 1.使用这个类能够读取输入管理器设置的按键,以及访问移动设备的多点触控或加速感应数据.想要读取轴向使用Input.GetAxis方法获取下列默认轴: "Horizontal&q ...

  3. Jenkins构建报错(Jenkins is reserved for jobs with matching label expression)解决办法

    Jenkins构建报错Jenkins is reserved for jobs with matching label expression 原因节点配置导致 修改配置

  4. ibatis sqlmap配置问题 “Check the IBatisNet.DataAccess.DaoSessionHandlers.SqlMapDaoSessionHandler.”

    - The error occurred while configure DaoSessionHandler.- The error occurred in <property name=&qu ...

  5. Codeforces Round #433 (Div. 2, based on Olympiad of Metropolises)

    A. Fraction 题目链接:http://codeforces.com/contest/854/problem/A 题目意思:给出一个数n,求两个数a+b=n,且a/b不可约分,如果存在多组满足 ...

  6. Centralized Cache Management in HDFS

    Overview(概述) Centralized cache management in HDFS is an explicit caching mechanism that allows users ...

  7. Oracle备份恢复之无备份情况下恢复undo表空间

    UNDO表空间存储着DML操作数据块的前镜像数据,在数据回滚,一致性读,闪回操作,实例恢复的时候都可能用到UNDO表空间中的数据.如果在生产过程中丢失或破坏了UNDO表空间,可能导致某些事务无法回滚, ...

  8. Oracle管理监控之Oracle用户权限

    数据字典 1.动态数据字典是以v$xxx开始的数据字典,在数据库中约有150个左右,这些数据字典反映数据库动态运行状况,在不同时间查询会得到不同的结果. 2.DBA数据字典是以DBA_xxx表示,该数 ...

  9. Oracle管理监控之rlwrap-0.37.tar.gz实现sqlplus上下翻页

    1.上传rlwrap-0.37.tar.gz到linux 2.解压rlwrap-0.37.tar.gz [root@node1 mnt]# tar zxvf rlwrap-0.37.tar.gz [r ...

  10. 自己封装framworks上传到应用商店报错

    参考链接: http://www.jianshu.com/p/60ac3ded34a0 http://ikennd.ac/blog/2015/02/stripping-unwanted-archite ...