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

专门做网站的公司交什么合肥室内设计

专门做网站的公司交什么,合肥室内设计,合肥网站开发公司电话,甘肃张掖网站建设结论#xff1a; 16 hooks版本 默认render1次 同步中#xff0c;无论多少种类还是次数#xff0c;都render 1次。 异步中#xff0c;无论多少种类还是次数#xff0c;1个种类执行1次#xff0c;多次的话#xff0c;用n*2。 18 hooks版本 默认render2次#xff0c; 同步…结论 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 (divp{countA}-{countB}/pbutton 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 (divp{countA}-{countB}/pbutton 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); // 操作步骤先点击弹窗然后快速按钮永远弹出的是016和18都这样子}, 3000);}return (div classNameAppp{number}/pbutton onClick{() setNumber(number 1)}/buttonbutton 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 classNameApph1{a}/h1button onClick{() {// react 16 刷新两次, 结果仍然为124 react18刷新一次setA(a1);setA(a1);}}fffff/button/div ); ---------------------------------------- const [number,setNumber] useState(0); function alertNumber(){setTimeout((){alert(number); // 不论您点击多少次下边的click这里就是0},3000); } return (p{number}/pbutton onClick{()setNumber(number1)}/buttonbutton 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 classNameApp onClick{aclick}{ca}/div); }
http://www.zqtcl.cn/news/223394/

相关文章:

  • 做的网站图片不显示2018做网站赚钱不
  • 国内建站平台网站建设是什么科目
  • 响应式个人网站psd建设银行网站联系电话
  • 大型网站开发实战品牌网站建设费用要多少
  • 昆山网站建设昆山html5制作手机端页面
  • 做网站的国标有哪些达州网络推广
  • 站内seo和站外seo区别wordpress演示数据
  • 建设旅游网站财务分析创意设计公司网站
  • 张家港网站优化wordpress调用图片上传
  • 做网站要商标吗房产网站 设计方案
  • 做网站的费用怎么做账客户案例 网站建设
  • 怎么查询网站的备案号城乡建设杂志网站
  • 婚恋网站哪家做的最好北斗导航2022最新版手机版
  • 别墅效果图网站重庆金融公司网站建设
  • 中兴能源建设有限公司网站企业营销策划及推广
  • 外贸英文网站制作WordPress对接微信公众号
  • 推广网站建设花费得多少钱哪些平台可以发布软文
  • wordpress网站检测购物app大全
  • 遵义建设厅官方网站 元丰兰州网站设计有限公司
  • 芜湖做网站的公司排名贵阳好的网站建设公司
  • 网站建设 骏域网站建设专家最有效的15个营销方法
  • 大连品牌官网建站为什么有些网站更新的信息看不到
  • 富阳市网站域名申请好了怎么做网站
  • 做药物分析必须知道的网站网站攻击一般有那些
  • 一般网站做哪些端口映射那个网站做境外自由行便宜
  • 网站的建站过程公司seo是什么意思
  • 胜利油田局域网主页入口seo自学网官网
  • 阜阳网站是网站开发与设计专业
  • 网站建设哪个品牌好网站新备案不能访问
  • 网站备案号申请流程华为企业文化