@webkrafters/react-observable-context 4.0.0-rc.4 → 4.0.0-rc.6
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 +10 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
</a>
|
|
14
14
|
<img alt="NPM" src="https://img.shields.io/npm/l/@webkrafters/react-observable-context">
|
|
15
15
|
<img alt="Maintenance" src="https://img.shields.io/maintenance/yes/2032">
|
|
16
|
-
<img alt="
|
|
16
|
+
<img alt="build size" src="https://img.shields.io/bundlephobia/minzip/@webkrafters/react-observable-context?label=bundle%20size">
|
|
17
17
|
<img alt="GitHub package.json version" src="https://img.shields.io/github/package-json/v/webKrafters/react-observable-context">
|
|
18
18
|
</p>
|
|
19
19
|
|
|
@@ -76,7 +76,7 @@ A property path is a dot-notation string leading to a specific property within a
|
|
|
76
76
|
|
|
77
77
|
<strong id="property-path-example">Ex. Given the following object:</strong>
|
|
78
78
|
|
|
79
|
-
```
|
|
79
|
+
```jsx
|
|
80
80
|
{
|
|
81
81
|
a: {
|
|
82
82
|
c: {
|
|
@@ -106,7 +106,7 @@ A selector map is an object holding key:value pairs.<br />
|
|
|
106
106
|
|
|
107
107
|
<strong id="selector-map-example">Example:</strong>
|
|
108
108
|
|
|
109
|
-
```
|
|
109
|
+
```jsx
|
|
110
110
|
// Given the following state object:
|
|
111
111
|
const state = {
|
|
112
112
|
a: 1,
|
|
@@ -186,7 +186,7 @@ Existing array state property can be overridden with a new array.<br />
|
|
|
186
186
|
Use the indexed object to update array content at indexes.<br />
|
|
187
187
|
<strong>Example:</strong>
|
|
188
188
|
|
|
189
|
-
```
|
|
189
|
+
```jsx
|
|
190
190
|
// Given the following array bearing state object:
|
|
191
191
|
const state = { a: { b: [ { x: 7, y: 8, z: 9 } ] }, j: 10 };
|
|
192
192
|
|
|
@@ -200,7 +200,7 @@ store.setState({ a: { b: { 0: { y: 30 }, 1: 22 } } });
|
|
|
200
200
|
|
|
201
201
|
// The previous statement is functionally equivalent to the following:
|
|
202
202
|
const [ first, second, ...rest ] = state.a.b;
|
|
203
|
-
store.setState({ ...state, a: { ...a, b: [ { ...first, y: 30 }, 22, ...rest ] } });
|
|
203
|
+
store.setState({ ...state, a: { ...state.a, b: [ { ...first, y: 30 }, 22, ...rest ] } });
|
|
204
204
|
// Refrain from doing this, please!
|
|
205
205
|
```
|
|
206
206
|
|
|
@@ -250,13 +250,13 @@ The React-Observable-Context module contains **4** exports namely:
|
|
|
250
250
|
# Usage
|
|
251
251
|
|
|
252
252
|
<i><b><u>context.js</u></b></i>
|
|
253
|
-
```
|
|
253
|
+
```jsx
|
|
254
254
|
import { createContext } from '@webkrafters/react-observable-context';
|
|
255
255
|
export default createContext();
|
|
256
256
|
```
|
|
257
257
|
|
|
258
258
|
<i><b><u>ui.js</u></b> (connect method)</i>
|
|
259
|
-
```
|
|
259
|
+
```jsx
|
|
260
260
|
import React, { useCallback, useEffect } from 'react';
|
|
261
261
|
import { connect } from '@webkrafters/react-observable-context';
|
|
262
262
|
import ObservableContext from './context';
|
|
@@ -287,7 +287,7 @@ export default Ui;
|
|
|
287
287
|
```
|
|
288
288
|
|
|
289
289
|
<i><b><u>ui.js</u></b> (useContext with memo method)</i>
|
|
290
|
-
```
|
|
290
|
+
```jsx
|
|
291
291
|
import React, { memo, useCallback, useEffect } from 'react';
|
|
292
292
|
import { useContext } from '@webkrafters/react-observable-context';
|
|
293
293
|
import ObservableContext from './context';
|
|
@@ -321,7 +321,7 @@ export default Ui;
|
|
|
321
321
|
```
|
|
322
322
|
|
|
323
323
|
<i id="provider-usage"><b><u>provider.js</u></b></i>
|
|
324
|
-
```
|
|
324
|
+
```jsx
|
|
325
325
|
import React, { useEffect, useState } from 'react';
|
|
326
326
|
import ObservableContext from './context';
|
|
327
327
|
import Ui from './ui';
|
|
@@ -377,7 +377,7 @@ export default Provider;
|
|
|
377
377
|
```
|
|
378
378
|
|
|
379
379
|
<i><b><u>index.js</u></b></i>
|
|
380
|
-
```
|
|
380
|
+
```jsx
|
|
381
381
|
import React from 'react';
|
|
382
382
|
import ReactDOM from 'react-dom';
|
|
383
383
|
import Provider from './provider';
|
package/package.json
CHANGED