Creating a useActions hook in React
Mar 1, 2021
設計一個簡單的 Action Creator
使用 react-redux 的 hook useDispatch
上面的例子中,如果每次執行 dispatch
都要放入名稱很長的 actionCreators
會顯得很冗。所以把 dispatch
和 actionCreators
一起抽離寫成 useActions
設計一個簡單的 Action Creator
使用 react-redux 的 hook useDispatch
上面的例子中,如果每次執行 dispatch
都要放入名稱很長的 actionCreators
會顯得很冗。所以把 dispatch
和 actionCreators
一起抽離寫成 useActions