[MST] Loading Data from the Server using lifecycle hook
Let's stop hardcoding our initial state and fetch it from the server instead.
In this lesson you will learn:
- Set up basic data fetching
- Leverage the
afterCreatelifecycle hook to automatically run any setup logic a model instance needs to do after creation
export const Group = types
.model({
users: types.map(User)
})
.actions(self => ({
// lifecycle hook
afterCreate() {
self.load()
},
load: flow(function* load() {
const response = yield window.fetch(`http://localhost:3001/users`)
applySnapshot(self.users, yield response.json())
})
}))
[MST] Loading Data from the Server using lifecycle hook的更多相关文章
- [转帖]Loading Data into HAWQ
Loading Data into HAWQ Leave a reply Loading data into the database is required to start using it bu ...
- Loading Data into HDFS
How to use a PDI job to move a file into HDFS. Prerequisites In order to follow along with this how- ...
- 使用OGG"Loading data from file to Replicat"的方法应该注意的问题:replicat进程是前台进程
使用OGG的 "Loading data from file to Replicat"的方法应该注意的问题:replicat进程是前台进程 因此.最好是在vncserver中调用该 ...
- OGG "Loading data from file to Replicat"table静态数据同步配置过程
OGG "Loading data from file to Replicat"table静态数据同步配置过程 一个.mgr过程 GGSCI (lei1) 3> view p ...
- Retrieving data from a server
A system includes a server and a controller embedded in a device. Both the server and the embedded c ...
- [React] Update State Based on Props using the Lifecycle Hook getDerivedStateFromProps in React16.3
getDerivedStateFromProps is lifecycle hook introduced with React 16.3 and intended as a replacement ...
- [React] Capture values using the lifecycle hook getSnapshotBeforeUpdate in React 16.3
getSnapshotBeforeUpdate is a lifecycle hook that was introduced with React 16.3. It is invoked right ...
- 6 ways to import data into SQL Server
I’m going to go over some methods to import data from text files into SQL Server today. The particul ...
- Transfer data to SQL Server from SPC-Light with Excel macros
公司的QA检测软件SPC-Light,需要从其中读取一些信息至SQL Server数据库,储存或是做其它分析. 先是在Excel的VBE的工具中,引入一个组件Microsoft ActiveX Dat ...
随机推荐
- python_字典的使用
'''info = { "stu1":"Lie","stu2":"Weite","stu3":&qu ...
- 前端和后台对接时对sign加密方法
前端和后台对接时对sign加密方法 /*后台php对接进行sign标签加密 1 获取向后台请求的数据data(key/value方式),可以是个对象(obj),也可以是数组(arr); 2 将数据的k ...
- Objective-C 和 Core Foundation 对象相互转换
iOS同意Objective-C 和 Core Foundation 对象之间能够轻松的转换: CFStringRef aCFString = (CFStringRef)aNSString; NSSt ...
- 【网络协议】TCP协议简单介绍
本文仅仅是对TCP协议做个简要的介绍. TCP协议,即传输控制协议.与UDP协议同处于传输层,相同使用相同的网络层,但TCP提供了一种可靠的.面向连接的传输数据服务,它会在两个使用TC ...
- Executors线程池关闭时间计算
Executors线程池关闭时间计算 学习了:http://blog.csdn.net/wo541075754/article/details/51564359 https://www.cnblogs ...
- 第十五章,读取txt文件(C++)
#include <iostream> #include <fstream> int main(int argc, char** argv) { std::ifstream i ...
- zzuoj--10400--海岛争霸(并查集)
10400: B.海岛争霸 Time Limit: 2 Sec Memory Limit: 128 MB Submit: 128 Solved: 46 [Submit][Status][Web B ...
- [jzoj 6084] [GDOI2019模拟2019.3.25] 礼物 [luogu 4916] 魔力环 解题报告(莫比乌斯反演+生成函数)
题目链接: https://jzoj.net/senior/#main/show/6084 https://www.luogu.org/problemnew/show/P4916 题目: 题解: 注: ...
- JavaScript原型链:prototype与__proto__
title: 'JavaScript原型链:prototype与__proto__' toc: false date: 2018-09-04 11:16:54 主要看了这一篇,讲解的很清晰,最主要的一 ...
- 记一次"未将对象引用设置到对象的实例"问题的排查过程
最近在给一个老项目做数据对接接口. 背景一 该项目最后更新日期为2006年,使用ASP.NET WebForm..Net2.0.OJB.Castle Avtive Record等.由于是某集团的子系统 ...