|
@@ -8,7 +8,9 @@ export class ComponentWrapper {
|
8
|
8
|
componentName: string,
|
9
|
9
|
OriginalComponentClass: React.ComponentType<any>,
|
10
|
10
|
store,
|
11
|
|
- componentEventsObserver): React.ComponentType<any> {
|
|
11
|
+ componentEventsObserver,
|
|
12
|
+ ReduxProvider?,
|
|
13
|
+ reduxStore?): React.ComponentType<any> {
|
12
|
14
|
|
13
|
15
|
class WrappedComponent extends React.Component<any, { componentId: string; allProps: {}; }> {
|
14
|
16
|
|
|
@@ -51,6 +53,25 @@ export class ComponentWrapper {
|
51
|
53
|
|
52
|
54
|
ReactLifecyclesCompat.polyfill(WrappedComponent);
|
53
|
55
|
require('hoist-non-react-statics')(WrappedComponent, OriginalComponentClass);
|
54
|
|
- return WrappedComponent;
|
|
56
|
+
|
|
57
|
+ if (reduxStore) {
|
|
58
|
+ return ComponentWrapper.wrapWithRedux(WrappedComponent, ReduxProvider, reduxStore);
|
|
59
|
+ } else {
|
|
60
|
+ return WrappedComponent;
|
|
61
|
+ }
|
|
62
|
+ }
|
|
63
|
+
|
|
64
|
+ static wrapWithRedux(WrappedComponent, ReduxProvider, reduxStore): React.ComponentType<any> {
|
|
65
|
+ class ReduxWrapper extends React.Component<any, any> {
|
|
66
|
+ render() {
|
|
67
|
+ return (
|
|
68
|
+ <ReduxProvider store={reduxStore}>
|
|
69
|
+ <WrappedComponent {...this.props} />
|
|
70
|
+ </ReduxProvider>
|
|
71
|
+ );
|
|
72
|
+ }
|
|
73
|
+ }
|
|
74
|
+ require('hoist-non-react-statics')(ReduxWrapper, WrappedComponent);
|
|
75
|
+ return ReduxWrapper;
|
55
|
76
|
}
|
56
|
77
|
}
|