Giter VIP home page Giter VIP logo

react-playground's Introduction

react-playground

创建操作

  • crateInstance(type, newProps, rootContainerInstance, _currentHostContext, workInProgress) 这是react-reconciler想要根据目标元素创建ui元素实例的地方,一般这里的目标为DOM元素, 这里使用document.createElement来创建type的DOM元素。type可以为DOM的元素名称比如divpimg等.

  • createTextInstance(text) 只有子元素是文本或者数字会进入此函数, 用于创建文本或数字节点 twitter讨论

UI 树操作

  • appendInitialChild(parentInstance, child) 调用此函数创建初始化ui树, 映射到domElemetn.appendChild. 将子元素附加到父元素种

  • appendChild(parentInstance, child) 这个方法和appendInitialChild类似, 用于后续的ui树操作

  • appendChildToContainer(container, child) 这个方法用于将子元素映射到跟元素种, 这时会形成真实的DOM

更新prop操作

  • finalizeInitialChildren 可以对children做一些初始化工作, 一般情况忽略

  • prepareUpdate 这里是需要我们对newProps和oldProps进行diff的地方, 这个函数是在commit还未提交钱进行计算, 这样可以跨越多个帧之间进行计算. 当一切准备好之后再commit整个树

  • commitUpdate 将newProps更新到元素种, r

  • commitTextUpdate 更新节点的值

  • removeChild 删除节点

react-playground's People

Contributors

monsterooo avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.