zoukankan      html  css  js  c++  java
  • [MST] Restore the Model Tree State using Hot Module Reloading when Model Definitions Change

    n this lesson, we will set up Hot Module Reloading(HMR), making it possible to load new definitions for React components and MST models and apply them to a running application.

    In this lesson you will learn:

    • How HMR roughly works
    • How to accept changes to components
    • How to accept changes to changing model definitions, while keeping state
    let wishList = WishList.create(initialState)
    
    function renderApp() {
        ReactDOM.render(<App wishList={wishList} />, document.getElementById("root"))
    }
    
    renderApp()
    
    if (module.hot) {
        module.hot.accept(["./components/App"], () => {
            // new components
            renderApp()
        })
    
        module.hot.accept(["./models/WishList"], () => {
            // new model definitions
            const snapshot = getSnapshot(wishList)
            wishList = WishList.create(snapshot)
            renderApp()
        })
    }
  • 相关阅读:
    IntentService源码分析
    startService过程源码分析
    洛谷P3300 城市规划
    agc033
    洛谷P3306 随机数生成器
    洛谷P3299 保护出题人
    洛谷P3298 泉
    洛谷P3296 刺客信条
    树hash
    我们都爱膜您退火!
  • 原文地址:https://www.cnblogs.com/Answer1215/p/8372792.html
Copyright © 2011-2022 走看看