[REF] store: replace ConnectedComponent by useStore hook

Closes #304
This commit is contained in:
Géry Debongnie
2019-10-08 09:14:41 +02:00
committed by aab-odoo
parent 19b10f7c1d
commit 895fe7c60f
15 changed files with 1182 additions and 1430 deletions
+19 -1
View File
@@ -15,6 +15,9 @@
- [`useContext`](#usecontext)
- [`useRef`](#useref)
- [`useSubEnv`](#usesubenv)
- [`useStore`](#usestore)
- [`useDispatch`](#usedispatch)
- [`useGetters`](#usegetters)
- [Making customized hooks](#making-customized-hooks)
## Overview
@@ -283,6 +286,21 @@ will be added to the parent environment. Note that it will extend, not replace
the parent environment. And of course, the parent environment will not be
affected.
### `useStore`
The `useStore` hook is the entry point for a component to connect to the store.
See the [store documentation](store.md) for more information.
### `useDispatch`
The `useDispatch` hook is the way for components to get a reference to the store
`dispatch` function. See the [store documentation](store.md) for more information.
### `useGetters`
The `useGetters` hook is the way for components to get a reference to the store
getters. See the [store documentation](store.md) for more information.
### Making customized hooks
Hooks are a wonderful way to organize the code of a complex component by feature
@@ -346,4 +364,4 @@ not the solution to every problem.
test our components, we can just add a mock router in the environment.
Note: the code above makes use of the `Component.current` property. This is the
way hooks are able to get a reference to the component currently being created.
way hooks are able to get a reference to the component currently being created.