@webkrafters/react-observable-context 2.1.4-rc.0 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,11 +4,13 @@ A context bearing an observable consumer store. State changes within the store's
|
|
|
4
4
|
|
|
5
5
|
**React::memo** *(and PureComponents)* remain the go-to solution for the repeated automatic re-renderings of entire component trees resulting from ***component*** state changes.
|
|
6
6
|
|
|
7
|
-
_**Recommendation:**_ For optimum performance, consider wrapping in **React::memo** most components using this package's ***useContext*** function either directly or through another React hook. This will protect such components and their descendants from unrelated cascading render operations.
|
|
7
|
+
_**Recommendation:**_ For optimum performance, consider wrapping in **React::memo** most components using this package's ***useContext*** function either directly or through another React hook. This will protect such components and their descendants from unrelated cascading render operations.
|
|
8
|
+
|
|
9
|
+
***Exempt*** from the recommendation are certain components such as those wrapped in the `React-Redux::connect()` Higher Order Component (HOC). Such HOC provides similar cascade-render protections to wrapped components and their descendants.
|
|
8
10
|
|
|
9
11
|
<hr />
|
|
10
12
|
|
|
11
|
-
<
|
|
13
|
+
<h3><u>Install</u></h3>
|
|
12
14
|
|
|
13
15
|
npm i -S @webkrafters/react-observable-context
|
|
14
16
|
|
|
@@ -16,7 +18,7 @@ npm install --save @webkrafters/react-observable-context
|
|
|
16
18
|
|
|
17
19
|
## API
|
|
18
20
|
|
|
19
|
-
The React-Observable-Context package exports **
|
|
21
|
+
The React-Observable-Context package exports **4** modules namely: the **createContext** method, the **useContext** hook, the **Provider** component and the **UsageError** class.
|
|
20
22
|
|
|
21
23
|
* **createContext** is a zero-parameter funtion returning a store-bearing context. Pass the context to the React::useContext() parameter to obtain the context's `store`.
|
|
22
24
|
|
|
@@ -24,6 +26,8 @@ The React-Observable-Context package exports **3** modules namely: the **createC
|
|
|
24
26
|
|
|
25
27
|
* **Provider** can immediately be used as-is anywhere the React-Observable-Context is required. It accepts **3** props and the customary Provider `children` prop. Supply the context to its `context` prop; the initial state to the customary Provider `value` prop; and the optional `prehooks` prop <i>(discussed in the prehooks section below)</i>.
|
|
26
28
|
|
|
29
|
+
* **UsageError** class is the Error type reported for attempts to access this context's store outside of its Provider component tree.
|
|
30
|
+
|
|
27
31
|
***<u>Note:</u>*** the Provider `context` prop is not updateable. Once set, all further updates to this prop are not recorded.
|
|
28
32
|
|
|
29
33
|
### The Store
|
package/package.json
CHANGED