[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
afterCreate
lifecycle 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 ...
随机推荐
- mycql 基本mysql语句(增删改查)
操作文件夹(库) 增 (增加一个库 db1 ) create database db1 charset utf8; 查 # 查看当前创建的数据库 show create database db1; # ...
- webpack操作基础
webpack 是一个前端加载/打包工具,根据模块的依赖关系进行静态分析,并依根据规则生成对应的静态资源
- Informatica PowerCenter使用介绍-转载
转载自:https://blog.csdn.net/wen_demon/article/details/44155639 1. INFORMATICA CLIENT的使用1.1 Repository ...
- POJ——T1125 Stockbroker Grapevine
http://poj.org/problem?id=1125 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 36045 ...
- poj3249 Test for job 【图的DAG dp】
#include <cstdio> #include <cstdlib> #include <iostream> #include <algorithm> ...
- linux下tomcat开机启动简单配置
1.个人标记 caicongyang http://blog.csdn.net/caicongyang 2.正文 在linux文件/etc/rc.d/rc.local的末尾加入例如以下行就可以: ex ...
- Java的接口总结
Java最主要的封装是class.除此之外还有接口interface. 这段时间一直在想接口有什么作用呢.有了接口有哪些优点呢.结合网络上各位大神的文章,接口的作用大概体如今下面几个方面. 1.回调 ...
- HDOJ 5299 Circles Game 圆嵌套+树上SG
将全部的圆化成树,然后就能够转化成树上的删边博弈问题.... Circles Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: ...
- java中的输入输出<1>
java中的输入输出基础(1) java中的IO支持通过java.io包下的类和接口来支持.在java.io包下主要包括输入.输出两种io流,每种输入.输出流又分为字节流和字符流. 字节流就是以字节为 ...
- nyoj--236--心急的C小加(动态规划&&LIS)
心急的C小加 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 C小加有一些木棒,它们的长度和质量都已经知道,需要一个机器处理这些木棒,机器开启的时候需要耗费一个单位的时间 ...