Skip to content

Instantly share code, notes, and snippets.

@kmsheng
Last active April 8, 2019 06:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmsheng/87445e3f798f76dc9fb91e5b6798618a to your computer and use it in GitHub Desktop.
Save kmsheng/87445e3f798f76dc9fb91e5b6798618a to your computer and use it in GitHub Desktop.
redux-react-hook / src / index.ts
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
import {create} from './create'; // 將 create 方法從檔案 create.ts 引入
// 底下呼叫 create 方法的 return 結果 StoreContext, useDispatch 和 useMappedState export 出去
// 這樣外部檔案可以使用 import 語法叫用
export const {StoreContext, useDispatch, useMappedState} = create<
any,
any,
any
>();
// 單獨把 create 方法 export 出去。這有兩個用途:
// 1. 給 TypeScript 用的 ( 外部檔案定義 IState 與 Action )
// 2. 如果你有多個 redux store
// https://github.com/kmsheng/redux-react-hook/tree/medium-20190408#create
export {create};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment