[MST] Restore the Model Tree State using Hot Module Reloading when Model Definitions Change
2024-08-27 08:40:21
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()
})
}
最新文章
- jQuery 参考手册 - 遍历
- FusionCharts V3图表导出图片和PDF属性说明(转)
- UIImageView属性
- 希尔排序(C++版)
- openssl rsa 加解密
- Kafka分布式消息模型
- 深入理解CSS3 Animation 帧动画(转)
- Swiftly语言学习1
- 解决百度BMR的spark集群开启slaves结点的问题
- wsimport 命令不是内部命令
- android下载管理、理财、浏览器、商品筛选、录音源码等
- Linux内存管理 (5)slab分配器
- @resource、@Autowired、@Service在一个接口多个实现类中的应用
- Oracle中 (+)与left join 的用法区别
- Gym - 100989M(dp)
- handsontable 拖动末尾列至前面列位置,被拖动列消失的问题
- WinForm通用自动更新器AutoUpdater项目实战
- 转: Xshell鼠标选中,终端立即中断(CTRL-C)的问题
- Nginx 为 Golang 配置 web 服务
- Linux服务器修改时区时间