@webkrafters/react-observable-context 2.1.0 → 2.1.1
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 +267 -324
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,324 +1,267 @@
|
|
|
1
|
-
# React-Observable-Context
|
|
2
|
-
|
|
3
|
-
A context bearing an observable consumer 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.
|
|
4
|
-
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
npm
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
* **
|
|
20
|
-
|
|
21
|
-
* **
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
The
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* **
|
|
32
|
-
|
|
33
|
-
* **
|
|
34
|
-
|
|
35
|
-
* **
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* **
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
import ObservableContext from './context';
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
<
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
)
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
import
|
|
230
|
-
import
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
<
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
<PriceSticker />
|
|
269
|
-
</Provider>
|
|
270
|
-
</div>
|
|
271
|
-
);
|
|
272
|
-
};
|
|
273
|
-
Product.displayName = 'Product';
|
|
274
|
-
|
|
275
|
-
export default Product;
|
|
276
|
-
|
|
277
|
-
<i><u>app.js</u></i>
|
|
278
|
-
|
|
279
|
-
import React, { useCallback, useMemo, useState } from 'react';
|
|
280
|
-
|
|
281
|
-
import Product from './product';
|
|
282
|
-
|
|
283
|
-
const App = () => {
|
|
284
|
-
|
|
285
|
-
const [ productType, setProductType ] = useState( 'Calculator' );
|
|
286
|
-
|
|
287
|
-
const updateType = useCallback( e => setProductType( e.target.value ), [] );
|
|
288
|
-
|
|
289
|
-
const prehooks = useMemo(() => ({
|
|
290
|
-
resetState: ( ...args ) => {
|
|
291
|
-
console.log( 'resetting state with >>>> ', JSON.stringify( args ) );
|
|
292
|
-
return true;
|
|
293
|
-
},
|
|
294
|
-
setState: ( ...args ) => {
|
|
295
|
-
console.log( 'setting state with >>>> ', JSON.stringify( args ) );
|
|
296
|
-
return true;
|
|
297
|
-
}
|
|
298
|
-
}), []);
|
|
299
|
-
|
|
300
|
-
return (
|
|
301
|
-
<div className="App">
|
|
302
|
-
<h1>Demo</h1>
|
|
303
|
-
<h2>A contrived product app.</h2>
|
|
304
|
-
<div style={{ marginBottom: 10 }}>
|
|
305
|
-
<label>Type: <input onKeyUp={ updateType } placeholder="override product type here..." /></label>
|
|
306
|
-
</div>
|
|
307
|
-
<Product prehooks={ prehooks } type={ productType } />
|
|
308
|
-
</div>
|
|
309
|
-
);
|
|
310
|
-
};
|
|
311
|
-
App.displayName = 'App';
|
|
312
|
-
|
|
313
|
-
export default App;
|
|
314
|
-
|
|
315
|
-
<i><u>index.js</i></b>
|
|
316
|
-
|
|
317
|
-
import React from 'react';
|
|
318
|
-
import ReactDOM from 'react-dom';
|
|
319
|
-
import App from './app';
|
|
320
|
-
ReactDOM.render(<App />, document.getElementById('root'));
|
|
321
|
-
|
|
322
|
-
## License
|
|
323
|
-
|
|
324
|
-
MIT
|
|
1
|
+
# React-Observable-Context
|
|
2
|
+
|
|
3
|
+
A context bearing an observable consumer 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.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
_**Recommendation:**_ Wrap all components calling this package's ***useContext*** function in **React::memo**. This will protect such component and its descendants from unrelated cascading render operations.
|
|
8
|
+
|
|
9
|
+
<h4><u>Install</u></h4>
|
|
10
|
+
|
|
11
|
+
npm i -S @webkrafters/react-observable-context
|
|
12
|
+
|
|
13
|
+
npm install --save @webkrafters/react-observable-context
|
|
14
|
+
|
|
15
|
+
## API
|
|
16
|
+
|
|
17
|
+
The React-Observable-Context package exports **3** modules namely: the **createContext** method, the **useContext** hook and the **Provider** component.
|
|
18
|
+
|
|
19
|
+
* **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`.
|
|
20
|
+
|
|
21
|
+
* **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.
|
|
22
|
+
|
|
23
|
+
* **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>.
|
|
24
|
+
|
|
25
|
+
***<u>Note:</u>*** the Provider `context` prop is not updateable. Once set, all further updates to this prop are not recorded.
|
|
26
|
+
|
|
27
|
+
### The Store
|
|
28
|
+
|
|
29
|
+
The context's `store` exposes **4** methods for interacting with the context's internal state namely:
|
|
30
|
+
|
|
31
|
+
* **getState**: (selector?: (state: State) => any) => any
|
|
32
|
+
|
|
33
|
+
* **resetState**: VoidFunction // resets the state to the Provider initial `value` prop.
|
|
34
|
+
|
|
35
|
+
* **setState**: (changes: PartialState\<State\>) => void // sets only new/changed top level properties.
|
|
36
|
+
|
|
37
|
+
* **subscribe**: (listener: (newValue: PartialState\<State\>, oldValue: PartialState\<State\>) => void) => ***UnsubscribeFunction***
|
|
38
|
+
|
|
39
|
+
### Prehooks
|
|
40
|
+
|
|
41
|
+
The context's store update operation adheres to **2** user supplied prehooks when present. Otherwise, the update operation proceeds normally to completion. They are named **resetState** and **setState** after the store update methods which utilize them.
|
|
42
|
+
|
|
43
|
+
* **resetState**: (state: {current: State, original: State}) => boolean
|
|
44
|
+
|
|
45
|
+
* **setState**: (newChanges: PartialState\<State\>) => boolean
|
|
46
|
+
|
|
47
|
+
***<u>Use case:</u>*** prehooks provide a central place for sanitizing, modifying, transforming, validating etc. all related incoming state updates. The prehook returns a **boolean** value (`true` to continue AND `false` to abort the update operation). The prehook may mutate (i.e. sanitize, transform, transpose) its argument values to accurately reflect the intended update value.
|
|
48
|
+
|
|
49
|
+
## Usage
|
|
50
|
+
|
|
51
|
+
<i><u>context.js</u></i>
|
|
52
|
+
|
|
53
|
+
import { createContext } from '@webkrafters/react-observable-context';
|
|
54
|
+
const ObservableContext = createContext();
|
|
55
|
+
export default ObservableContext;
|
|
56
|
+
|
|
57
|
+
<i><u>reset.js</u></i>
|
|
58
|
+
|
|
59
|
+
import React, { memo, useEffect } from 'react';
|
|
60
|
+
import { useContext } from '@webkrafters/react-observable-context';
|
|
61
|
+
import ObservableContext from './context';
|
|
62
|
+
const Reset = memo(() => {
|
|
63
|
+
const { resetState } = useContext( ObservableContext );
|
|
64
|
+
useEffect(() => console.log( 'Reset component rendered.....' ));
|
|
65
|
+
return ( <button onClick={ resetState }>reset context</button> );
|
|
66
|
+
});
|
|
67
|
+
Reset.displayName = 'Reset';
|
|
68
|
+
export default Reset;
|
|
69
|
+
|
|
70
|
+
<i><u>tally-display.js</u></i>
|
|
71
|
+
|
|
72
|
+
import React, { memo, useEffect } from 'react';
|
|
73
|
+
import { useContext } from '@webkrafters/react-observable-context';
|
|
74
|
+
import ObservableContext from './context';
|
|
75
|
+
import Reset from './reset';
|
|
76
|
+
const CONTEXT_KEYS = [ 'color', 'price', 'type' ];
|
|
77
|
+
const TallyDisplay = memo(() => {
|
|
78
|
+
const { getState } = useContext( ObservableContext, CONTEXT_KEYS );
|
|
79
|
+
useEffect(() => console.log( 'TallyDisplay component rendered.....' ));
|
|
80
|
+
return (
|
|
81
|
+
<div>
|
|
82
|
+
<table>
|
|
83
|
+
<tbody>
|
|
84
|
+
<tr><td><label>Type:</label></td><td>{ getState( s => s.type ) }</td></tr>
|
|
85
|
+
<tr><td><label>Color:</label></td><td>{ getState( s => s.color ) }</td></tr>
|
|
86
|
+
<tr><td><label>Price:</label></td><td>{ getState( s => s.price ).toFixed( 2 ) }</td></tr>
|
|
87
|
+
</tbody>
|
|
88
|
+
</table>
|
|
89
|
+
<div style={{ textAlign: 'right' }}>
|
|
90
|
+
<Reset />
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
TallyDisplay.displayName = 'TallyDisplay';
|
|
96
|
+
export default TallyDisplay;
|
|
97
|
+
|
|
98
|
+
<i><u>editor.js</u></i>
|
|
99
|
+
|
|
100
|
+
import React, { memo, useCallback, useEffect, useRef } from 'react';
|
|
101
|
+
import { useContext } from '@webkrafters/react-observable-context';
|
|
102
|
+
import ObservableContext from './context';
|
|
103
|
+
const Editor = memo(() => {
|
|
104
|
+
const { setState } = useContext( ObservableContext );
|
|
105
|
+
const priceInputRef = useRef();
|
|
106
|
+
const colorInputRef = useRef();
|
|
107
|
+
const typeInputRef = useRef();
|
|
108
|
+
const updatePrice = useCallback(() => {
|
|
109
|
+
setState({ price: Number( priceInputRef.current.value ) });
|
|
110
|
+
}, []);
|
|
111
|
+
const updateColor = useCallback(() => {
|
|
112
|
+
setState({ color: colorInputRef.current.value });
|
|
113
|
+
}, []);
|
|
114
|
+
const updateType = useCallback(() => {
|
|
115
|
+
setState({ type: typeInputRef.current.value });
|
|
116
|
+
}, []);
|
|
117
|
+
useEffect(() => console.log( 'Editor component rendered.....' ));
|
|
118
|
+
return (
|
|
119
|
+
<fieldset style={{ margin: '10px 0' }}>
|
|
120
|
+
<legend>Editor</legend>
|
|
121
|
+
<div style={{ margin: '10px 0' }}>
|
|
122
|
+
<label>New Price: <input ref={ priceInputRef } /></label>
|
|
123
|
+
{ ' ' }
|
|
124
|
+
<button onClick={ updatePrice }>update price</button>
|
|
125
|
+
</div>
|
|
126
|
+
<div style={{ margin: '10px 0' }}>
|
|
127
|
+
<label>New Color: <input ref={ colorInputRef } /></label>
|
|
128
|
+
{ ' ' }
|
|
129
|
+
<button onClick={ updateColor }>update color</button>
|
|
130
|
+
</div>
|
|
131
|
+
<div style={{ margin: '10px 0' }}>
|
|
132
|
+
<label>New Type: <input ref={ typeInputRef } /></label>
|
|
133
|
+
{ ' ' }
|
|
134
|
+
<button onClick={ updateType }>update type</button>
|
|
135
|
+
</div>
|
|
136
|
+
</fieldset>
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
Editor.displayName = 'Editor';
|
|
140
|
+
export default Editor;
|
|
141
|
+
|
|
142
|
+
<i><u>product-description.js</u></i>
|
|
143
|
+
|
|
144
|
+
import React, { memo, useEffect } from 'react';
|
|
145
|
+
import { useContext } from '@webkrafters/react-observable-context';
|
|
146
|
+
import ObservableContext from './context';
|
|
147
|
+
const CONTEXT_KEYS = [ 'color', 'type' ];
|
|
148
|
+
const ProductDescription = memo(() => {
|
|
149
|
+
const store = useContext( ObservableContext, CONTEXT_KEYS );
|
|
150
|
+
useEffect(() => console.log( 'ProductDescription component rendered.....' ));
|
|
151
|
+
const color = store.getState( s => s.color );
|
|
152
|
+
const type = store.getState( s => s.type );
|
|
153
|
+
return (
|
|
154
|
+
<div style={{ fontSize: 24 }}>
|
|
155
|
+
<strong>Description:</strong> { color } { type }
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
});
|
|
159
|
+
ProductDescription.displayName = 'ProductDescription';
|
|
160
|
+
export default ProductDescription;
|
|
161
|
+
|
|
162
|
+
<i><u>price-sticker.js</u></i>
|
|
163
|
+
|
|
164
|
+
import React, { memo, useEffect } from 'react';
|
|
165
|
+
import { useContext } from '@webkrafters/react-observable-context';
|
|
166
|
+
import ObservableContext from './context';
|
|
167
|
+
const CONTEXT_KEYS = [ 'price' ];
|
|
168
|
+
const PriceSticker = memo(() => {
|
|
169
|
+
const { getState } = useContext( ObservableContext, CONTEXT_KEYS );
|
|
170
|
+
useEffect(() => console.log( 'PriceSticker component rendered.....' ));
|
|
171
|
+
return (
|
|
172
|
+
<div style={{ fontSize: 36, fontWeight: 800 }}>
|
|
173
|
+
${ getState( s => s.price ).toFixed( 2 ) }
|
|
174
|
+
</div>
|
|
175
|
+
);
|
|
176
|
+
});
|
|
177
|
+
PriceSticker.displayName = 'PriceSticker';
|
|
178
|
+
export default PriceSticker;
|
|
179
|
+
|
|
180
|
+
<i><u>product.js</u></i>
|
|
181
|
+
|
|
182
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
183
|
+
import { Provider } from '@webkrafters/react-observable-context';
|
|
184
|
+
import ObservableContext from './context';
|
|
185
|
+
import Editor from './editor';
|
|
186
|
+
import PriceSticker from './price-sticker';
|
|
187
|
+
import ProductDescription from './product-description';
|
|
188
|
+
import TallyDisplay from './tally-display';
|
|
189
|
+
const Product = ({ prehooks = undefined, type }) => {
|
|
190
|
+
const [ state, setState ] = useState(() => ({
|
|
191
|
+
color: 'Burgundy',
|
|
192
|
+
price: 22.5,
|
|
193
|
+
type
|
|
194
|
+
}));
|
|
195
|
+
useEffect(() => {
|
|
196
|
+
setState({ type }); // use this to update only the changed state
|
|
197
|
+
// setState({ ...state, type }); // this will reset the context internal state
|
|
198
|
+
}, [ type ]);
|
|
199
|
+
const overridePricing = useCallback( e => setState({ price: Number( e.target.value ) }), [] );
|
|
200
|
+
return (
|
|
201
|
+
<div>
|
|
202
|
+
<div style={{ marginBottom: 10 }}>
|
|
203
|
+
<label>$ <input onKeyUp={ overridePricing } placeholder="override price here..."/></label>
|
|
204
|
+
</div>
|
|
205
|
+
<Provider
|
|
206
|
+
context={ ObservableContext }
|
|
207
|
+
prehooks={ prehooks }
|
|
208
|
+
value={ state }
|
|
209
|
+
>
|
|
210
|
+
<div style={{
|
|
211
|
+
borderBottom: '1px solid #333',
|
|
212
|
+
marginBottom: 10,
|
|
213
|
+
paddingBottom: 5
|
|
214
|
+
}}>
|
|
215
|
+
<Editor />
|
|
216
|
+
<TallyDisplay />
|
|
217
|
+
</div>
|
|
218
|
+
<ProductDescription />
|
|
219
|
+
<PriceSticker />
|
|
220
|
+
</Provider>
|
|
221
|
+
</div>
|
|
222
|
+
);
|
|
223
|
+
};
|
|
224
|
+
Product.displayName = 'Product';
|
|
225
|
+
export default Product;
|
|
226
|
+
|
|
227
|
+
<i><u>app.js</u></i>
|
|
228
|
+
|
|
229
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
230
|
+
import Product from './product';
|
|
231
|
+
const prehooks = {
|
|
232
|
+
resetState: ( ...args ) => {
|
|
233
|
+
console.log( 'resetting state with >>>> ', JSON.stringify( args ) );
|
|
234
|
+
return true;
|
|
235
|
+
},
|
|
236
|
+
setState: ( ...args ) => {
|
|
237
|
+
console.log( 'setting state with >>>> ', JSON.stringify( args ) );
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
const App = () => {
|
|
242
|
+
const [ productType, setProductType ] = useState( 'Calculator' );
|
|
243
|
+
const updateType = useCallback( e => setProductType( e.target.value ), [] );
|
|
244
|
+
return (
|
|
245
|
+
<div className="App">
|
|
246
|
+
<h1>Demo</h1>
|
|
247
|
+
<h2>A contrived product app.</h2>
|
|
248
|
+
<div style={{ marginBottom: 10 }}>
|
|
249
|
+
<label>Type: <input onKeyUp={ updateType } placeholder="override product type here..." /></label>
|
|
250
|
+
</div>
|
|
251
|
+
<Product prehooks={ prehooks } type={ productType } />
|
|
252
|
+
</div>
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
App.displayName = 'App';
|
|
256
|
+
export default App;
|
|
257
|
+
|
|
258
|
+
<i><u>index.js</i></b>
|
|
259
|
+
|
|
260
|
+
import React from 'react';
|
|
261
|
+
import ReactDOM from 'react-dom';
|
|
262
|
+
import App from './app';
|
|
263
|
+
ReactDOM.render(<App />, document.getElementById('root'));
|
|
264
|
+
|
|
265
|
+
## License
|
|
266
|
+
|
|
267
|
+
MIT
|
package/package.json
CHANGED