zoukankan      html  css  js  c++  java
  • react_9

    setState异步问题(数据改变后不能马上操作DOM)

    setState第二个参数是回调函数

    纯组件(内置了shouldComponentUpdate())

    componenet改变成PureComponent会变成纯组件

    react-redux内置了shouldComponentUpdate()

    路由的update

    在路由router中写个onUpdate
    

    promise

    http://www.ruanyifeng.com/blog/2011/08/a_detailed_explanation_of_jquery_deferred_object
    

    高阶组件

    调用一个函数传递给这个函数一个组件,这个函数会返回一个新的组件

    ### connect函数的底层实现原理
    connect = (mapState, mapDispatch) => {
    	return (UIComponent) => {
    		return class ContainerComponent extends React.Component {
    			getChildContext(context){    //在constructor函数前执行
    				this.store = context.state
    			}
    
    			constructor(props){
    				super(props)
    				const state = {}
    				for (var i in mapState) {
    					state[i] = this.store.state[i]
    				}
    				this.state = state
    			}
    
    			render() {
    				<UIComponent {...state}></UIComponent>
    			}
    		}
    	}
    }
    

    前端渲染

    1. seo搜索引擎不友好
    2. 首屏展示慢
    

    网页发送http是最慢的

    服务器端渲染

    浏览器可以解析虚拟dom

    nuxt服务器端渲染框架

    nuxtnext(react服务器端渲染框架)

  • 相关阅读:
    【Web-Components】document.registerElement
    Date
    类型转换
    【Web-Components】HTML imports
    【Web-Components】
    【Web-Components】Shadow Dom
    【Mobile】
    数据库读写分离
    HDU——T 1711 Number Sequence
    洛谷——P2957 [USACO09OCT]谷仓里的回声Barn Echoes
  • 原文地址:https://www.cnblogs.com/lhh-bky/p/8424066.html
Copyright © 2011-2022 走看看