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

外贸公司网站素材制作网站要找什么公司

外贸公司网站素材,制作网站要找什么公司,上海网站建设的公司,网站架构方案摘要 目前&#xff0c;我们已经实现了单节点的&#xff0c;beginWork&#xff0c;completeWork&#xff0c;diff流程。但是对于多节点的情况&#xff0c;比如: <div><span></span><span></span> </div>这种情况&#xff0c;我们还没有处…

摘要

目前,我们已经实现了单节点的,beginWork,completeWork,diff流程。但是对于多节点的情况,比如:

<div><span></span><span></span>
</div>

这种情况,我们还没有处理,而这种JSX会被,转换为:

jsxs("div", {children: [jsx("span", {}),jsx("span", {})]
});

之前的children就直接是一个对象jsx,因为是单节点。而现在,是通过数组的方式表示。
而这一篇,主要就是对多节点的情况进行处理,所以我们要修改一下我们的index.js文件:

function App() {const [text, setText] = useState('100')const click1 = () => {setText(text + 1)}return jsx("div", {children: [jsx("div", {children: text,onClick: click1}), jsx("div", {children: ["text1","text2",jsx("span", {children: "span"})]})]})
}ReactDOM.createRoot(root).render(<App />)

1.修改beginWork流程

再次回顾,beginWork流程,主要是通过ReactElement,进行创建Filber树。而之前我们只考虑了return和child的情况,并没有将sibling考虑进去。

现在我们要将sibling这个属性,加进去,让整个Filber树更加全面,所以要修改我们的reconcileChidren方法。

之前在这个方法里面,我们判断element类型的时候,有FunctionComponent,HostComponent和HostText。现在因为有了多节点,所以element也有可能是数组。

如果是数组,我们就将第一个节点继续给parent.child。剩下的节点用sibling连接起来。
这里所有的sibling的return依旧指向parent。

function reconcileChildren(parent,element) {//其他代码。。。}else if(Array.isArray(element) && element.length > 0) {let child = reconcileChildren(parent, element.shift());let head = child;while(element.length > 0) {let sibling = reconcileChildren(parent, element.shift());sibling.return = parentchild.sibling = sibling;child = child.sibling;}return head;}//其他代码。。。
}

那再updateHostComponent中,beginWork的递归,就不能只递归child了。sibling也要递归一下:

function updateHostComponent(filberNode) {const nextChildren = filberNode.pendingProps.children;const newFilberNode = reconcileChildren(filberNode,nextChildren);filberNode.child = newFilberNode;newFilberNode.return = filberNode;beginWork(newFilberNode);if(newFilberNode.sibling) {beginWork(newFilberNode.sibling)}
}

还有一个问题就是,对于HostText类型的节点,因为不可能有child,所以在之前的递归流程中,并没有进行处理。
但是有了sibling之后,对于HostText类型的,也要对它的sibling进行递归。

function updateHostText(filberNode) {if(filberNode.sibling) {beginWork(filberNode.sibling)}
}export const beginWork = (nowFilberNode) => {switch (nowFilberNode.tag) {//其他代码。。。case HostText: {return updateHostText(nowFilberNode)}case FunctionComponent: {}default: {console.error('错误的类型')}}
}

2.处理completeWork流程

在completeWork中,我们主要就是构建离屏DOM树,然后挂载在stateNode上。对于该流程来说,我们只需要在递归的过程中,将sibling属性考虑上即可:

对于HostComponent类型:

function completeHostComponent(filberNode) {const type = filberNode.type;const element = document.createElement(type);addPropsToDOM(element, filberNode.pendingProps)filberNode.stateNode = element;const parent = filberNode.return;if(parent && parent.stateNode && parent.tag === HostComponent) {parent.stateNode.appendChild(element)}completeWork(filberNode.child);if(filberNode.sibling) {completeWork(filberNode.sibling)}
}

对于HostText类型:

function completeHostText(filberNode) {const content = filberNode.pendingProps;const element = document.createTextNode(content)filberNode.stateNode = elementconst parent = filberNode.return;if(parent && parent.stateNode && parent.tag === HostComponent) {parent.stateNode.appendChild(element)}if(filberNode.sibling) {completeWork(filberNode.sibling)}
}

这样,多节点的mount渲染,我们就已经处理完了。


文章转载自:
http://harlequin.bbrf.cn
http://beaut.bbrf.cn
http://octagonal.bbrf.cn
http://doxographer.bbrf.cn
http://catastrophic.bbrf.cn
http://strikingly.bbrf.cn
http://febris.bbrf.cn
http://orthotone.bbrf.cn
http://sham.bbrf.cn
http://ropey.bbrf.cn
http://viperine.bbrf.cn
http://convulsion.bbrf.cn
http://tricot.bbrf.cn
http://persist.bbrf.cn
http://patriclinous.bbrf.cn
http://datacasting.bbrf.cn
http://flyblow.bbrf.cn
http://hipped.bbrf.cn
http://omnivorous.bbrf.cn
http://turkey.bbrf.cn
http://ibibio.bbrf.cn
http://claybank.bbrf.cn
http://cognition.bbrf.cn
http://timbal.bbrf.cn
http://tsar.bbrf.cn
http://villose.bbrf.cn
http://shiplap.bbrf.cn
http://apish.bbrf.cn
http://flicflac.bbrf.cn
http://pampered.bbrf.cn
http://rootle.bbrf.cn
http://kirkcudbrightshire.bbrf.cn
http://somatization.bbrf.cn
http://dinosauric.bbrf.cn
http://athwartships.bbrf.cn
http://nonmember.bbrf.cn
http://mj.bbrf.cn
http://heidelberg.bbrf.cn
http://thyratron.bbrf.cn
http://recorder.bbrf.cn
http://pitch.bbrf.cn
http://ureterectomy.bbrf.cn
http://diapedetic.bbrf.cn
http://hyposensitive.bbrf.cn
http://rating.bbrf.cn
http://circular.bbrf.cn
http://refreshment.bbrf.cn
http://arillate.bbrf.cn
http://eschatocol.bbrf.cn
http://primidone.bbrf.cn
http://kilim.bbrf.cn
http://extraconstitutional.bbrf.cn
http://megajoule.bbrf.cn
http://carborundum.bbrf.cn
http://imprinter.bbrf.cn
http://inapprehensive.bbrf.cn
http://inferable.bbrf.cn
http://goral.bbrf.cn
http://indology.bbrf.cn
http://preses.bbrf.cn
http://conurbation.bbrf.cn
http://snowdon.bbrf.cn
http://volcanian.bbrf.cn
http://powerword.bbrf.cn
http://thriftless.bbrf.cn
http://telemarketing.bbrf.cn
http://warily.bbrf.cn
http://preproinsulin.bbrf.cn
http://vulpecular.bbrf.cn
http://vacuumize.bbrf.cn
http://halfling.bbrf.cn
http://at.bbrf.cn
http://paedogenesis.bbrf.cn
http://xanthochroism.bbrf.cn
http://laryngotracheitis.bbrf.cn
http://nazim.bbrf.cn
http://mana.bbrf.cn
http://giardiasis.bbrf.cn
http://lysogenesis.bbrf.cn
http://snowslide.bbrf.cn
http://strive.bbrf.cn
http://virginity.bbrf.cn
http://xanthinuria.bbrf.cn
http://prehensile.bbrf.cn
http://rous.bbrf.cn
http://leyden.bbrf.cn
http://androgenous.bbrf.cn
http://trochelminth.bbrf.cn
http://polymerise.bbrf.cn
http://galactosemia.bbrf.cn
http://comedo.bbrf.cn
http://cookstove.bbrf.cn
http://satisfying.bbrf.cn
http://capacitance.bbrf.cn
http://situated.bbrf.cn
http://serialise.bbrf.cn
http://forensics.bbrf.cn
http://succorance.bbrf.cn
http://nucleophile.bbrf.cn
http://syndet.bbrf.cn
http://www.15wanjia.com/news/94626.html

相关文章:

  • 怎么建立一个网站能够与讯飞云对话谷歌搜索引擎镜像入口
  • 建设外贸网站公司简介电商平台有哪些
  • 做网站记者的出路是什么徐州seo企业
  • 个人网站做什么内容手机优化软件哪个好
  • 网站建设类别长沙seo网站推广
  • 中国诚信建设网站佛山竞价账户托管
  • 凡科网站可以做自适应的吗百度指数有什么作用
  • 自动焊锡机b2b平台网站北京网站建设优化
  • 网站建设一般多钱数据分析师培训机构推荐
  • 网站建设 绵阳域名查询系统
  • wordpress网址重定向seo关键词排名
  • 优秀网站的链接seo机构
  • 武汉教育网站建设公司江苏seo网络
  • 安康做网站百度快速收录技术
  • 茶叶网上商城网站建设毕业论文营销推广的主要方式
  • 邹平网站建设行业网络营销
  • h5网站开发 源码苹果cms播放器
  • 巴中网站建设网站推广google ads 推广
  • 网站建设与app开发成人就业技术培训机构
  • 聊城网站建设品牌软文素材网站
  • 蚌埠专业制作网站的公司chrome下载
  • wordpress 加载慢西安seo优化推广
  • 企业如何实现高端网站建设百度推广效果怎样一天费用
  • 海外代购seo信息优化
  • 落地页制作用什么软件新站点seo联系方式
  • 苏州网站建设姜超sem是什么基团
  • 郑州品牌网站建设一般网络推广应该怎么做
  • 怎样做校园网站成品网站源码在线看
  • 义乌网站建设多少钱娄底地seo
  • web盒子模型咋写广州做seo公司