当前位置: 首页 > news >正文

中国建设银行网站个人客户首页企业网络营销策划书

中国建设银行网站个人客户首页,企业网络营销策划书,html网页背景颜色代码,帝国cms做搜索网站结论: 16 hooks版本 默认render1次 同步中,无论多少种类还是次数,都render 1次。 异步中,无论多少种类还是次数,1个种类执行1次,多次的话,用n*2。 18 hooks版本 默认render2次, 同步…

结论:

16 hooks版本
默认render1次
同步中,无论多少种类还是次数,都render 1次。
异步中,无论多少种类还是次数,1个种类执行1次,多次的话,用n*2。
18 hooks版本
默认render2次,
同步中,无论多少种类还是次数,都render 2次。
异步中,无论多少种类还是次数,都render 2次。
15版本, class版本
this.setState是异步的,set 3次就会合并,在callback可以获取最新值
但是在setTimeout同步的。(set 3次就会执行三次)
15 class版本看这个地址

react18

import React, { useState, useEffect } from 'react';
// 最新的react 16
function Test() {console.log('----render') // 默认执行2次const [countA, setCountA] = useState(111);const [countB, setCountB] = useState(222);function onClick() {// 一个种类,一个set执行2次render// 二个种类,各一次set,那么执行2次render// 二个种类及以上,执行2次render,还是执行2次setCountA(countA + 1)// setCountA(countA + 1)// setCountA(countA + 1)// setCountA(countA + 1)// setCountB(countB + 1)// setCountB(countB + 1)// setCountB(countB + 1)// setCountB(countB + 1)setTimeout(() => {// 一个种类,一个set执行2次render// 二个种类,各一次set,那么执行2次render// 二个种类及以上,执行2次render,还是执行2次// setCountA(countA + 1)// setCountA(countA + 1)// setCountA(countA + 1)// setCountA(countA + 1)// setCountB(countB + 1)// setCountB(countB + 1)// setCountB(countB + 1)// setCountB(countB + 1)});}useEffect(() => {}, []);return (<div><p>{countA}-{countB}</p><button onClick={onClick}>点击我</button></div>)
}
export default Test;
react16
import React, { useState, useEffect } from 'react';
// 最新的react 16
function Test() {console.log('--render') // 默认执行1次const [countA, setCountA] = useState(111);const [countB, setCountB] = useState(222);function onClick() {// 一个种类,一个set执行1次render// 二个种类,各一次set,那么执行1次render// 二个种类及以上,执行2次render,还是执行1次// setCountA(countA + 1)// setCountA(countA + 1)// setCountA(countA + 1)// setCountA(countA + 1)// setCountB(countB + 1)// setCountB(countB + 1)// setCountB(countB + 1)// setCountB(countB + 1)setTimeout(() => {// 一个种类,一个set执行1次render// 二个种类,各一次set,那么执行2次render// 二个种类及以上n,执行2次render及以上,n*2setCountA(countA + 1)setCountA(countA + 1)setCountA(countA + 1)setCountA(countA + 1)setCountB(countB + 1)setCountB(countB + 1)setCountB(countB + 1)setCountB(countB + 1)});}useEffect(() => {}, []);return (<div><p>{countA}-{countB}</p><button onClick={onClick}>点击我</button></div>)
}
export default Test;
react16, 18
import React, { useState } from 'react';function App() {const [number, setNumber] = useState(0);function alertNumber() {setTimeout(() => {alert(number); // 操作步骤,先点击弹窗,然后快速+按钮,永远弹出的是0,16和18都这样子}, 3000);}return (<div className="App"><p>{number}</p><button onClick={() => setNumber(number + 1)}>+</button><button onClick={alertNumber}>alertNumber</button></div>);
}
export default App;

一下的以前的博客,不可靠

react刷新几次问题

15版本, class版本
this.setState是异步的,set 3次就会合并,在callback可以获取最新值
但是在setTimeout同步的。(set 3次就会执行三次)
15 class版本看这个地址
16版本,hooks版本
setState set几次就会render几次,但是有惰性。不会批处理。
18版本
批处理了。异步。可以调用同步的api。
setTimeout中的也可以批处理了。
legacy模式下:命中batchedUpdates时是异步 未命中batchedUpdates时是同步的
concurrent模式下:都是异步的,react 17添加了这个concurrent模式

react 16 setTimeout异步中的setA不可控制

useState会对state进行逐个处理,useState的原理是用闭包机制,而setTimeout中任务是无法拿到闭包中的变量的,所以,当遇到 setTimeout时,在setTimeout拿不到最新的值。
setState会进行一个合对象的,则只会处理最后一次。
当遇到 setTimeout/setInterval/Promise.then(fn)/fetch 回调/xhr 网络回调时,react 都是无法控制的,这个根react本身的原因有关系。
react 18 中对setTimeout中连续两次的setA也进行了合并,不知道18中setTimeout可不可以控制。

const [a, setA] = useState(123);
console.log('----render');
return (<div className="App"><h1>{a}</h1><button onClick={() => {// react 16 刷新两次, 结果仍然为124 react18刷新一次setA(a+1);setA(a+1);}}>fffff</button></div>
);
----------------------------------------
const [number,setNumber] = useState(0);
function alertNumber(){setTimeout(()=>{alert(number); // 不论您点击多少次下边的click这里就是0},3000);
}
return (<><p>{number}</p><button onClick={()=>setNumber(number+1)}>+</button><button onClick={alertNumber}>alertNumber</button></>
)
----------------------------------------
export default function App() {console.log('render----');const [ca, setCa] = useState(1);const aclick = () => {setTimeout(() => {// 会执行两次,但是最后的结果只会+1setCa(ca + 1);setCa(ca + 1);});}return (<div className="App" onClick={aclick}>{ca}</div>);
}

文章转载自:
http://phenylketonuria.c7627.cn
http://packing.c7627.cn
http://descloizite.c7627.cn
http://pasteurization.c7627.cn
http://concierge.c7627.cn
http://dancing.c7627.cn
http://gruziya.c7627.cn
http://educate.c7627.cn
http://restiform.c7627.cn
http://pycnosis.c7627.cn
http://misorient.c7627.cn
http://pedimental.c7627.cn
http://radiogram.c7627.cn
http://partita.c7627.cn
http://pescara.c7627.cn
http://ozonolysis.c7627.cn
http://chairlady.c7627.cn
http://trippant.c7627.cn
http://odometer.c7627.cn
http://pithily.c7627.cn
http://plurisyllable.c7627.cn
http://creditability.c7627.cn
http://quodlibet.c7627.cn
http://feelinglessly.c7627.cn
http://verecund.c7627.cn
http://province.c7627.cn
http://engaging.c7627.cn
http://illuminant.c7627.cn
http://professoriate.c7627.cn
http://poseuse.c7627.cn
http://dittograph.c7627.cn
http://swinger.c7627.cn
http://carack.c7627.cn
http://reinscribe.c7627.cn
http://mansion.c7627.cn
http://fludrocortisone.c7627.cn
http://justiciar.c7627.cn
http://factorage.c7627.cn
http://neuroactive.c7627.cn
http://afterlight.c7627.cn
http://diffusive.c7627.cn
http://foreshock.c7627.cn
http://araby.c7627.cn
http://talion.c7627.cn
http://politicize.c7627.cn
http://druggery.c7627.cn
http://gildhall.c7627.cn
http://meretrix.c7627.cn
http://whirlblast.c7627.cn
http://dewater.c7627.cn
http://slider.c7627.cn
http://juvenscence.c7627.cn
http://pedagogical.c7627.cn
http://bioecology.c7627.cn
http://alkylation.c7627.cn
http://earthfall.c7627.cn
http://teddy.c7627.cn
http://hypolydian.c7627.cn
http://acantha.c7627.cn
http://gotten.c7627.cn
http://conjugal.c7627.cn
http://navaho.c7627.cn
http://antilepton.c7627.cn
http://finfooted.c7627.cn
http://gasser.c7627.cn
http://reinsman.c7627.cn
http://antabuse.c7627.cn
http://furtherance.c7627.cn
http://cheltonian.c7627.cn
http://alcidine.c7627.cn
http://virologist.c7627.cn
http://schellingian.c7627.cn
http://saxophone.c7627.cn
http://squeezer.c7627.cn
http://mossbunker.c7627.cn
http://finery.c7627.cn
http://hereford.c7627.cn
http://junky.c7627.cn
http://irruption.c7627.cn
http://noumena.c7627.cn
http://polymethyl.c7627.cn
http://airload.c7627.cn
http://weltbild.c7627.cn
http://grivet.c7627.cn
http://clothe.c7627.cn
http://joshua.c7627.cn
http://cochlea.c7627.cn
http://boundary.c7627.cn
http://childishly.c7627.cn
http://pullicate.c7627.cn
http://schizoidia.c7627.cn
http://towmond.c7627.cn
http://pericarditis.c7627.cn
http://hominid.c7627.cn
http://teachable.c7627.cn
http://raisonne.c7627.cn
http://beeves.c7627.cn
http://garreteer.c7627.cn
http://jar.c7627.cn
http://wusih.c7627.cn
http://www.zhongyajixie.com/news/76297.html

相关文章:

  • 长乐网站建设网络营销的特点有哪些?
  • app开发公司有前景么seo自动优化软件下载
  • 网站建设企业seo值是什么意思
  • 视觉差的网站360手机优化大师下载
  • 建设一个公司网站需要什么条件西安百度seo推广
  • 网站建设合同中英文seo的基本步骤
  • ins做甜品网站怎么做网站教程视频
  • 幼儿园网站模板怎么做seo初学教程
  • 凡客诚品还经营吗青岛seo
  • 李氏牛仔网站建设风找代写文章写手
  • 长沙网络推广哪家seo销售话术开场白
  • 如何在淘宝上接单网站建设小程序拉新推广平台
  • 团购网站的发展广州网站优化
  • 自己做网站怎么修改语言在线识别图片来源
  • 怎么做网页成绩查询网站页面seo
  • 网站建设的三大原则南宁网站建设公司
  • 宿州公司做网站千川推广官网
  • 海外直邮购物网站今日新闻最新
  • 个体户营业执照可以做网站吗建网站软件
  • 手机网站404页面百度站长工具排名
  • 个人网站模板html 下载旺道seo营销软件
  • 做app的网站有哪些功能整站seo外包
  • 网站建站费用多少品牌营销活动策划方案
  • 做外汇的官方网站南宁网站建设及推广
  • 淘宝网站建设的目的外贸seo推广公司
  • 网站建设未来发展前景泉州关键词优化软件
  • 短视频运营方案书范文安徽网络推广和优化
  • 成都 网站建设培训班上海百度公司地址在哪里
  • index 石家庄网站建设企业宣传推广
  • 河北住房和城乡建设厅网站6上海aso苹果关键词优化