@webkrafters/react-observable-context 2.1.8 → 2.1.9

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.
Files changed (2) hide show
  1. package/README.md +9 -9
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # React-Observable-Context
2
2
 
3
- A context bearing an observable consumer store.
3
+ Only re-renders subscribing components on context state change. A subscribing component decides which context state properties' change trigger its update.
4
4
 
5
5
  **Name:** React-Observable-Context
6
6
 
@@ -12,11 +12,11 @@ npm install --save @webkrafters/react-observable-context
12
12
 
13
13
  # Intro
14
14
 
15
- State changes within the store's internal state are only broadcasted to components subscribed to the store. In this way, the `React-Observable-Context` prevents repeated automatic re-renderings of entire component trees resulting from ***context*** state changes.
15
+ A context bearing an observable consumer [store](#store). State changes within the store's internal state are only broadcasted to components subscribed to the store. In this way, the `React-Observable-Context` prevents repeated automatic re-renderings of entire component trees resulting from ***context*** state changes.
16
16
 
17
17
  **React::memo** *(and PureComponents)* remain the go-to solution for the repeated automatic re-renderings of entire component trees resulting from ***component*** state changes.
18
18
 
19
- _**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.
19
+ ***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.
20
20
 
21
21
  ***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.
22
22
 
@@ -24,17 +24,17 @@ _**Recommendation:**_ For optimum performance, consider wrapping in **React::mem
24
24
 
25
25
  The React-Observable-Context package exports **4** modules namely: the **createContext** method, the **useContext** hook, the **Provider** component and the **UsageError** class.
26
26
 
27
- * **createContext** is a zero-parameter function returning a store-bearing context. Pass the context to the useContext() parameter to obtain the context's `store`.
27
+ * **createContext** is a zero-parameter function returning a store-bearing context. Pass the context as a `context` parameter to the [useContext()](#usecontext) to obtain the context's [store](#store).
28
28
 
29
- * **useContext** is analogous to React::useContext hook but returns the context store and takes a second parameter named ***watchedKeys***. The `watchedKeys` parameter is a list of state object property paths to watch. A change in any of the referenced properties automatically triggers a render of the component calling this hook.
29
+ * <b id="usecontext">useContext</b> is analogous to React::useContext hook but returns the context store and takes a second parameter named ***watchedKeys***. The `watchedKeys` parameter is a list of state object property paths to watch. A change in any of the referenced properties automatically triggers a render of the component calling this hook.
30
30
 
31
- * **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>.
31
+ * **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](#prehooks) section below)</i>.
32
32
 
33
33
  * **UsageError** class is the Error type reported for attempts to access this context's store outside of its Provider component tree.
34
34
 
35
35
  ***<u>Note:</u>*** the Provider `context` prop is not updateable. Once set, all further updates to this prop are not recorded.
36
36
 
37
- ## The Store
37
+ ## Store
38
38
 
39
39
  The context's `store` exposes **4** methods for interacting with the context's internal state namely:
40
40
 
@@ -43,8 +43,8 @@ The context's `store` exposes **4** methods for interacting with the context's i
43
43
  * **resetState**: VoidFunction // resets the state to the Provider initial `value` prop.
44
44
 
45
45
  * **setState**: (changes: PartialState\<State\>) => void // sets only new/changed state slices.\
46
- ***Do this:*** `setState({stateKey0: changes0[, ...]});`\
47
- ***Not this:*** `setState({stateKey0: {...state.stateKey0, ...changes0}[, ...]});`
46
+ ***Do this:*** <code style="color:#080">setState({stateKey0: changes0[, ...]});</code>\
47
+ ***Not this:*** <code style="color:#800">setState({stateKey0: {...state.stateKey0, ...changes0}[, ...]});</code>
48
48
 
49
49
  * **subscribe**: (listener: (newValue: PartialState\<State\>, oldValue: PartialState\<State\>) => void) => ***UnsubscribeFunction***
50
50
 
package/package.json CHANGED
@@ -79,5 +79,5 @@
79
79
  "test:watch": "eslint --fix && jest --updateSnapshot --watchAll"
80
80
  },
81
81
  "types": "dist/index.d.ts",
82
- "version": "2.1.8"
82
+ "version": "2.1.9"
83
83
  }