会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
谢本寅
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
3
4
5
6
7
8
9
10
11
下一页
2021年12月9日
diff算法和渲染/更新流程
摘要: 渲染流程 首先会执行 render 方法拿到组件的结构 如果拿到的结构是 jsx 则会调用 React.createElement() 生成虚拟 DOM 根据虚拟 DOM 生成真实 DOM 更新流程 组件的 props 或 this.state 发生改变时执行 render() 方法 执行完 ren
阅读全文
posted @ 2021-12-09 21:52 霸哥yyds
阅读(106)
评论(0)
推荐(0)
2021年12月7日
Portals
摘要: Portals基本使用 import React from 'react'; import ReactDOM from 'react-dom' class Modal extends React.Component { render() { return ReactDOM.createPortal(
阅读全文
posted @ 2021-12-07 21:57 霸哥yyds
阅读(163)
评论(0)
推荐(0)
严格模式
摘要: 严格模式 import ReactDOM from 'react-dom' import React from "react"; import App from "./App"; ReactDOM.render(<React.StrictMode> <App/> </React.StrictMode
阅读全文
posted @ 2021-12-07 21:42 霸哥yyds
阅读(39)
评论(0)
推荐(0)
Fragments减少DOM的渲染
摘要: Fragments组件使用 import React from 'react'; class App extends React.Component { constructor(props) { super(props); } render() { return ( <React.Fragment
阅读全文
posted @ 2021-12-07 21:32 霸哥yyds
阅读(69)
评论(0)
推荐(0)
受控组件是什么
摘要: 受控组件 import React from 'react'; class App extends React.Component { constructor(props) { super(props); this.state = { name: 'xiebenyin' } } render() {
阅读全文
posted @ 2021-12-07 21:18 霸哥yyds
阅读(202)
评论(0)
推荐(0)
使用ref的注意点
摘要: 获取类组件 import React from 'react' class Home extends React.Component { render() { return ( <div>我是类组件</div> ) } } class App extends React.Component { co
阅读全文
posted @ 2021-12-07 00:04 霸哥yyds
阅读(117)
评论(0)
推荐(0)
2021年12月6日
ref属性获取DOM元素
摘要: 原生方法获取DOM(不推荐) import React from 'react';class App extends React.Component { constructor(props) { super(props); } render() { return ( <div> <h1 id={'b
阅读全文
posted @ 2021-12-06 23:32 霸哥yyds
阅读(981)
评论(0)
推荐(0)
2021年12月5日
不常用的生命周期方法
摘要: 不常用的生命周期方法 挂载时 静态方法 static getDerivedStateFromProps 会在 constructor 之后 render 之前调用 static getDerivedStateFromProps 静态方法接收两个参数父组件传递过来的 props 和自身的 state
阅读全文
posted @ 2021-12-05 00:09 霸哥yyds
阅读(42)
评论(0)
推荐(0)
2021年12月4日
常用的生命周期函数
摘要: React生命周期分为3个阶段 挂载时 首先会调用 constructor 创建组件,这里可以通过 props 接收父组件传递过来的数据,可以通过 this.state 初始化组件自己的数据 然后调用 render 渲染组件,主要是返回组件的结构 当组件渲染完毕后调用 componentDidMou
阅读全文
posted @ 2021-12-04 23:31 霸哥yyds
阅读(48)
评论(0)
推荐(0)
跨组件通信 (3)
摘要: 子组件将数据传递给父组件 import React from 'react'; class Son extends React.Component { constructor(props) { super(props); this.state = { name: 'xiebenyin' } } re
阅读全文
posted @ 2021-12-04 15:03 霸哥yyds
阅读(46)
评论(0)
推荐(0)
上一页
1
···
3
4
5
6
7
8
9
10
11
下一页