- Gives access to a single DOM element
- Create refs in the constructor, assign them to instance variables, then pass to a particular JSX elements as props.
2019年4月2日 星期二
React: Refs
Redux: Thunk
What's a thunk?
Thunk廣泛指的是: 延後執行的wrapper。
// calculation of 1 + 2 is immediate
// x === 3
let x = 1 + 2;
// calculation of 1 + 2 is delayed
// foo can be called later to perform the calculation
// foo is a thunk!
let foo = () => 1 + 2;
Thunk in Redux:
在Redux中的Thunk應用則是指"延後執行Dispatch"。
Thunk middleware 會幫助dispatch async action, 等待action 執行完畢後再 dispatch 內容至store,達到非同步。
這個dispatch 的內容並非帶值的 action,而是一個async function,執行完畢前皆未有值;執行完畢後,此async function 將另外寫一個dispatch,自行再次dispatch至store (這次的dispatch就如同一般的同步disptch function一樣)。
訂閱:
文章 (Atom)
Git: How to clone only part of the repo (specific directory)
https://stackoverflow.com/a/60729017/5721873
-
https://stackoverflow.com/a/60729017/5721873
-
Usage: To route for only one component in the Switch tag. import { Router, Route, Switch } from 'react-router-dom' ; ... ...
-
Gives access to a single DOM element Create refs in the constructor, assign them to instance variables, then pass to a particular JSX ele...