From e5b364ead4b65f8cbd8374dcab765ea262f4ab00 Mon Sep 17 00:00:00 2001 From: ChenYong Date: Mon, 11 Mar 2019 20:25:41 +0800 Subject: [PATCH] document syntax of hooks --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 9eb21fd..93caa2a 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,20 @@ export default class Inside extends React.PureComponent { } ``` +Or use hooks(Caution: it rerenders on every change) with `useRexContext`: + +```tsx +let HooksChild: SFC = (props) => { + let contextData = useRexContext((store: IGlobalStore) => { + return { data: store.data }; + }); + + return ( +
{JSON.stringify(contextData, null, 2)}
+ ); +}; +``` + ### Workflow https://github.com/jimengio/ts-workflow