react源码分析
2015-09-24 15:43
435 查看
ReactMount.render -> ReactMount._renderSubtreeIntoContainer
-> ReactMount._renderNewRootComponent -> ReactMount.batchedMountComponentIntoNode
-> ReactReconciler.mountComponent -> ReactDomComponent.mountComponent
-> ReactDomComponent._createContentMarkup ->ReactMultiChild.mountChildren
-> ReactMount._mountImageIntoNode -> ReactMount.setInnerHTML
ReactMount._mountImageIntoNode负责将virtualdom实际mount到dom上,
先是用ReactMarkupChecksum.canReuseMarkup检查是不是可以复用的markup
Transaction
-> ReactMount._renderNewRootComponent -> ReactMount.batchedMountComponentIntoNode
-> ReactReconciler.mountComponent -> ReactDomComponent.mountComponent
-> ReactDomComponent._createContentMarkup ->ReactMultiChild.mountChildren
-> ReactMount._mountImageIntoNode -> ReactMount.setInnerHTML
ReactMount._mountImageIntoNode负责将virtualdom实际mount到dom上,
先是用ReactMarkupChecksum.canReuseMarkup检查是不是可以复用的markup
/** * Mounting is the process of initializing a React component by creating its * representative DOM elements and inserting them into a supplied `container`. * Any prior content inside `container` is destroyed in the process. * * ReactMount.render( * component, * document.getElementById('container') * ); * * <div id="container"> <-- Supplied `container`. * <div data-reactid=".3"> <-- Rendered reactRoot of React * // ... component. * </div> * </div> * * Inside of `container`, the first element rendered is the "reactRoot". */
if (transaction.useCreateElement) { while (container.lastChild) { container.removeChild(container.lastChild); } container.appendChild(markup); } else { setInnerHTML(container, markup); }
Transaction
/* * Use cases: * - Preserving the input selection ranges before/after reconciliation. * Restoring selection even in the event of an unexpected error. * - Deactivating events while rearranging the DOM, preventing blurs/focuses, * while guaranteeing that afterwards, the event system is reactivated. * - Flushing a queue of collected DOM mutations to the main UI thread after a * reconciliation takes place in a worker thread. * - Invoking any collected `componentDidUpdate` callbacks after rendering new * content. * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue * to preserve the `scrollTop` (an automatic scroll aware DOM). * - (Future use case): Layout calculations before and after DOM updates. * * Transactional plugin API: * - A module that has an `initialize` method that returns any precomputation. * - and a `close` method that accepts the precomputation. `close` is invoked * when the wrapped process is completed, or has failed. * * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules * that implement `initialize` and `close`. * @return {Transaction} Single transaction for reuse in thread. * * @class Transaction */
相关文章推荐
- react-native试玩(35)-react-native-icons插件
- React开发需要的那些坑
- React组件的生命周期及其方法
- ReactiveCocoa比较区分replay, replayLast和replayLazily
- Tutorial #Facebook Relay文档翻译#
- Java reactor使用注意事项
- Start React Native In Android
- Facebook:我们是如何构建第一个跨平台的 React Native APP
- 用ReactJS写的简单组件Pagebar(待完善。。。)
- ReactiveCocoa & MVVM 学习总结二
- ReactiveCocoa & MVVM 学习总结一
- Getting Start #Facebook Relay文档翻译#
- React的一些。
- ReactiveCocoa2实战
- React Native通信机制详解
- react的入门讲解
- Android samples API Demos之UI篇1(ActionBarCompat-ShareActionProvider)
- ReactNative Android 研究
- React 入门实例教程总结
- 颠覆式前端UI开发框架:React