mobx-react 5.3.6 → 5.4.3
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/.browserlistrc +6 -6
- package/.editorconfig +6 -6
- package/.prettierrc +4 -4
- package/.travis.yml +9 -9
- package/CHANGELOG.md +518 -505
- package/LICENSE +21 -21
- package/README.md +517 -515
- package/custom.d.ts +140 -140
- package/custom.js +91 -66
- package/custom.module.js +88 -63
- package/empty.js +3 -3
- package/index.d.ts +140 -140
- package/index.js +91 -66
- package/index.min.js +1 -1
- package/index.module.js +88 -63
- package/native.d.ts +140 -140
- package/native.js +88 -63
- package/package.json +7 -5
- package/yarn.lock +5886 -5863
package/custom.d.ts
CHANGED
|
@@ -1,140 +1,140 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Turns a React component or stateless render function into a reactive component.
|
|
3
|
-
*/
|
|
4
|
-
import * as React from "react"
|
|
5
|
-
|
|
6
|
-
export type IReactComponent<P = any> =
|
|
7
|
-
| React.StatelessComponent<P>
|
|
8
|
-
| React.ComponentClass<P>
|
|
9
|
-
| React.ClassicComponentClass<P>
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Observer
|
|
13
|
-
*/
|
|
14
|
-
|
|
15
|
-
// Deprecated: observer with with stores (as decorator)
|
|
16
|
-
export function observer(stores: string[]): <T extends IReactComponent>(clazz: T) => void
|
|
17
|
-
// Deprecated: observer with with stores
|
|
18
|
-
export function observer<T extends IReactComponent>(stores: string[], clazz: T): T
|
|
19
|
-
export function observer<T extends IReactComponent>(target: T): T
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Inject
|
|
23
|
-
*/
|
|
24
|
-
export type IValueMap = { [key: string]: any }
|
|
25
|
-
export type IStoresToProps<
|
|
26
|
-
S extends IValueMap = {},
|
|
27
|
-
P extends IValueMap = {},
|
|
28
|
-
I extends IValueMap = {},
|
|
29
|
-
C extends IValueMap = {}
|
|
30
|
-
> = (stores: S, nextProps: P, context: C) => I
|
|
31
|
-
|
|
32
|
-
export type IWrappedComponent<P> = {
|
|
33
|
-
wrappedComponent: IReactComponent<P>
|
|
34
|
-
wrappedInstance: React.ReactInstance | undefined
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Ideally we would want to return React.ComponentClass<Partial<P>>,
|
|
38
|
-
// but TS doesn't allow such things in decorators, like we do in the non-decorator version
|
|
39
|
-
// See also #256
|
|
40
|
-
export function inject(
|
|
41
|
-
...stores: string[]
|
|
42
|
-
): <T extends IReactComponent<any>>(
|
|
43
|
-
target: T
|
|
44
|
-
) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never)
|
|
45
|
-
export function inject<S, P, I, C>(
|
|
46
|
-
fn: IStoresToProps<S, P, I, C>
|
|
47
|
-
): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>
|
|
48
|
-
|
|
49
|
-
// Ideal implementation:
|
|
50
|
-
// export function inject
|
|
51
|
-
// (
|
|
52
|
-
// fn: IStoresToProps
|
|
53
|
-
// ):
|
|
54
|
-
// <P>(target: IReactComponent<P>) => IReactComponent<Partial<P>> & IWrappedComponent<IReactComponent<Partial<P>>>
|
|
55
|
-
//
|
|
56
|
-
// Or even better: (but that would require type inference to work other way around)
|
|
57
|
-
// export function inject<P, I>
|
|
58
|
-
// (
|
|
59
|
-
// fn: IStoresToProps<any, P, I>
|
|
60
|
-
// ):
|
|
61
|
-
// <T extends IReactComponent<P & S>(target: T) => IReactComponent<P> & IWrappedComponent<T>
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* disposeOnUnmount
|
|
65
|
-
*/
|
|
66
|
-
type Disposer = () => void
|
|
67
|
-
export function disposeOnUnmount(target: React.Component<any, any>, propertyKey: string): void
|
|
68
|
-
export function disposeOnUnmount<TF extends Disposer | Disposer[]>(
|
|
69
|
-
target: React.Component<any, any>,
|
|
70
|
-
fn: TF
|
|
71
|
-
): TF
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Utilities
|
|
75
|
-
*/
|
|
76
|
-
export function onError(cb: (error: Error) => void): () => void
|
|
77
|
-
|
|
78
|
-
export class Provider extends React.Component<any, {}> {}
|
|
79
|
-
|
|
80
|
-
export class Observer extends React.Component<
|
|
81
|
-
{
|
|
82
|
-
children?: () => React.ReactNode
|
|
83
|
-
render?: () => React.ReactNode
|
|
84
|
-
},
|
|
85
|
-
{}
|
|
86
|
-
> {}
|
|
87
|
-
|
|
88
|
-
export function useStaticRendering(value: boolean): void
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Enable dev tool support, makes sure that renderReport emits events.
|
|
92
|
-
*/
|
|
93
|
-
export function trackComponents(): void
|
|
94
|
-
|
|
95
|
-
export const renderReporter: RenderReporter
|
|
96
|
-
|
|
97
|
-
export interface RenderReporter {
|
|
98
|
-
on(handler: (data: IRenderEvent) => void): void
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export interface IRenderEvent {
|
|
102
|
-
event: "render" | "destroy"
|
|
103
|
-
renderTime?: number
|
|
104
|
-
totalTime?: number
|
|
105
|
-
component: React.ReactElement<any> // Component instance
|
|
106
|
-
node: any // DOMNode
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* WeakMap DOMNode -> Component instance
|
|
111
|
-
* @deprecated
|
|
112
|
-
*/
|
|
113
|
-
export const componentByNodeRegistery: any
|
|
114
|
-
/**
|
|
115
|
-
* WeakMap DOMNode -> Component instance
|
|
116
|
-
*/
|
|
117
|
-
export const componentByNodeRegistry: any
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* @deprecated, use PropTypes instead
|
|
121
|
-
*/
|
|
122
|
-
export const propTypes: {
|
|
123
|
-
observableArray: React.Requireable<any>
|
|
124
|
-
observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
125
|
-
observableMap: React.Requireable<any>
|
|
126
|
-
observableObject: React.Requireable<any>
|
|
127
|
-
arrayOrObservableArray: React.Requireable<any>
|
|
128
|
-
arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
129
|
-
objectOrObservableObject: React.Requireable<any>
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
export const PropTypes: {
|
|
133
|
-
observableArray: React.Requireable<any>
|
|
134
|
-
observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
135
|
-
observableMap: React.Requireable<any>
|
|
136
|
-
observableObject: React.Requireable<any>
|
|
137
|
-
arrayOrObservableArray: React.Requireable<any>
|
|
138
|
-
arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
139
|
-
objectOrObservableObject: React.Requireable<any>
|
|
140
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Turns a React component or stateless render function into a reactive component.
|
|
3
|
+
*/
|
|
4
|
+
import * as React from "react"
|
|
5
|
+
|
|
6
|
+
export type IReactComponent<P = any> =
|
|
7
|
+
| React.StatelessComponent<P>
|
|
8
|
+
| React.ComponentClass<P>
|
|
9
|
+
| React.ClassicComponentClass<P>
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Observer
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
// Deprecated: observer with with stores (as decorator)
|
|
16
|
+
export function observer(stores: string[]): <T extends IReactComponent>(clazz: T) => void
|
|
17
|
+
// Deprecated: observer with with stores
|
|
18
|
+
export function observer<T extends IReactComponent>(stores: string[], clazz: T): T
|
|
19
|
+
export function observer<T extends IReactComponent>(target: T): T
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Inject
|
|
23
|
+
*/
|
|
24
|
+
export type IValueMap = { [key: string]: any }
|
|
25
|
+
export type IStoresToProps<
|
|
26
|
+
S extends IValueMap = {},
|
|
27
|
+
P extends IValueMap = {},
|
|
28
|
+
I extends IValueMap = {},
|
|
29
|
+
C extends IValueMap = {}
|
|
30
|
+
> = (stores: S, nextProps: P, context: C) => I
|
|
31
|
+
|
|
32
|
+
export type IWrappedComponent<P> = {
|
|
33
|
+
wrappedComponent: IReactComponent<P>
|
|
34
|
+
wrappedInstance: React.ReactInstance | undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Ideally we would want to return React.ComponentClass<Partial<P>>,
|
|
38
|
+
// but TS doesn't allow such things in decorators, like we do in the non-decorator version
|
|
39
|
+
// See also #256
|
|
40
|
+
export function inject(
|
|
41
|
+
...stores: string[]
|
|
42
|
+
): <T extends IReactComponent<any>>(
|
|
43
|
+
target: T
|
|
44
|
+
) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never)
|
|
45
|
+
export function inject<S, P, I, C>(
|
|
46
|
+
fn: IStoresToProps<S, P, I, C>
|
|
47
|
+
): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>
|
|
48
|
+
|
|
49
|
+
// Ideal implementation:
|
|
50
|
+
// export function inject
|
|
51
|
+
// (
|
|
52
|
+
// fn: IStoresToProps
|
|
53
|
+
// ):
|
|
54
|
+
// <P>(target: IReactComponent<P>) => IReactComponent<Partial<P>> & IWrappedComponent<IReactComponent<Partial<P>>>
|
|
55
|
+
//
|
|
56
|
+
// Or even better: (but that would require type inference to work other way around)
|
|
57
|
+
// export function inject<P, I>
|
|
58
|
+
// (
|
|
59
|
+
// fn: IStoresToProps<any, P, I>
|
|
60
|
+
// ):
|
|
61
|
+
// <T extends IReactComponent<P & S>(target: T) => IReactComponent<P> & IWrappedComponent<T>
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* disposeOnUnmount
|
|
65
|
+
*/
|
|
66
|
+
type Disposer = () => void
|
|
67
|
+
export function disposeOnUnmount(target: React.Component<any, any>, propertyKey: string): void
|
|
68
|
+
export function disposeOnUnmount<TF extends Disposer | Disposer[]>(
|
|
69
|
+
target: React.Component<any, any>,
|
|
70
|
+
fn: TF
|
|
71
|
+
): TF
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Utilities
|
|
75
|
+
*/
|
|
76
|
+
export function onError(cb: (error: Error) => void): () => void
|
|
77
|
+
|
|
78
|
+
export class Provider extends React.Component<any, {}> {}
|
|
79
|
+
|
|
80
|
+
export class Observer extends React.Component<
|
|
81
|
+
{
|
|
82
|
+
children?: () => React.ReactNode
|
|
83
|
+
render?: () => React.ReactNode
|
|
84
|
+
},
|
|
85
|
+
{}
|
|
86
|
+
> {}
|
|
87
|
+
|
|
88
|
+
export function useStaticRendering(value: boolean): void
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Enable dev tool support, makes sure that renderReport emits events.
|
|
92
|
+
*/
|
|
93
|
+
export function trackComponents(): void
|
|
94
|
+
|
|
95
|
+
export const renderReporter: RenderReporter
|
|
96
|
+
|
|
97
|
+
export interface RenderReporter {
|
|
98
|
+
on(handler: (data: IRenderEvent) => void): void
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface IRenderEvent {
|
|
102
|
+
event: "render" | "destroy"
|
|
103
|
+
renderTime?: number
|
|
104
|
+
totalTime?: number
|
|
105
|
+
component: React.ReactElement<any> // Component instance
|
|
106
|
+
node: any // DOMNode
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* WeakMap DOMNode -> Component instance
|
|
111
|
+
* @deprecated
|
|
112
|
+
*/
|
|
113
|
+
export const componentByNodeRegistery: any
|
|
114
|
+
/**
|
|
115
|
+
* WeakMap DOMNode -> Component instance
|
|
116
|
+
*/
|
|
117
|
+
export const componentByNodeRegistry: any
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* @deprecated, use PropTypes instead
|
|
121
|
+
*/
|
|
122
|
+
export const propTypes: {
|
|
123
|
+
observableArray: React.Requireable<any>
|
|
124
|
+
observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
125
|
+
observableMap: React.Requireable<any>
|
|
126
|
+
observableObject: React.Requireable<any>
|
|
127
|
+
arrayOrObservableArray: React.Requireable<any>
|
|
128
|
+
arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
129
|
+
objectOrObservableObject: React.Requireable<any>
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const PropTypes: {
|
|
133
|
+
observableArray: React.Requireable<any>
|
|
134
|
+
observableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
135
|
+
observableMap: React.Requireable<any>
|
|
136
|
+
observableObject: React.Requireable<any>
|
|
137
|
+
arrayOrObservableArray: React.Requireable<any>
|
|
138
|
+
arrayOrObservableArrayOf: (type: React.Validator<any>) => React.Requireable<any>
|
|
139
|
+
objectOrObservableObject: React.Requireable<any>
|
|
140
|
+
}
|
package/custom.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', '
|
|
4
|
-
(factory((global.mobxReact = {}),global.
|
|
5
|
-
}(this, (function (exports,React
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mobx'), require('react')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'mobx', 'react'], factory) :
|
|
4
|
+
(factory((global.mobxReact = {}),global.mobx,global.React));
|
|
5
|
+
}(this, (function (exports,mobx,React) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var React__default = 'default' in React ? React['default'] : React;
|
|
8
8
|
|
|
@@ -116,33 +116,35 @@
|
|
|
116
116
|
|
|
117
117
|
var reactIs_production_min = createCommonjsModule(function (module, exports) {
|
|
118
118
|
Object.defineProperty(exports,"__esModule",{value:!0});
|
|
119
|
-
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.forward_ref"):60112,
|
|
120
|
-
function
|
|
121
|
-
exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===
|
|
122
|
-
exports.isForwardRef=function(a){return
|
|
119
|
+
var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,r=b?Symbol.for("react.memo"):
|
|
120
|
+
60115,t=b?Symbol.for("react.lazy"):60116;function u(a){if("object"===typeof a&&null!==a){var q=a.$$typeof;switch(q){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case h:return a;default:return q}}case d:return q}}}function v(a){return u(a)===m}exports.typeOf=u;exports.AsyncMode=l;exports.ConcurrentMode=m;exports.ContextConsumer=k;exports.ContextProvider=h;exports.Element=c;exports.ForwardRef=n;exports.Fragment=e;
|
|
121
|
+
exports.Profiler=g;exports.Portal=d;exports.StrictMode=f;exports.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n)};exports.isAsyncMode=function(a){return v(a)||u(a)===l};exports.isConcurrentMode=v;exports.isContextConsumer=function(a){return u(a)===k};exports.isContextProvider=function(a){return u(a)===h};
|
|
122
|
+
exports.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};exports.isForwardRef=function(a){return u(a)===n};exports.isFragment=function(a){return u(a)===e};exports.isProfiler=function(a){return u(a)===g};exports.isPortal=function(a){return u(a)===d};exports.isStrictMode=function(a){return u(a)===f};
|
|
123
123
|
});
|
|
124
124
|
|
|
125
125
|
unwrapExports(reactIs_production_min);
|
|
126
126
|
var reactIs_production_min_1 = reactIs_production_min.typeOf;
|
|
127
127
|
var reactIs_production_min_2 = reactIs_production_min.AsyncMode;
|
|
128
|
-
var reactIs_production_min_3 = reactIs_production_min.
|
|
129
|
-
var reactIs_production_min_4 = reactIs_production_min.
|
|
130
|
-
var reactIs_production_min_5 = reactIs_production_min.
|
|
131
|
-
var reactIs_production_min_6 = reactIs_production_min.
|
|
132
|
-
var reactIs_production_min_7 = reactIs_production_min.
|
|
133
|
-
var reactIs_production_min_8 = reactIs_production_min.
|
|
134
|
-
var reactIs_production_min_9 = reactIs_production_min.
|
|
135
|
-
var reactIs_production_min_10 = reactIs_production_min.
|
|
136
|
-
var reactIs_production_min_11 = reactIs_production_min.
|
|
137
|
-
var reactIs_production_min_12 = reactIs_production_min.
|
|
138
|
-
var reactIs_production_min_13 = reactIs_production_min.
|
|
139
|
-
var reactIs_production_min_14 = reactIs_production_min.
|
|
140
|
-
var reactIs_production_min_15 = reactIs_production_min.
|
|
141
|
-
var reactIs_production_min_16 = reactIs_production_min.
|
|
142
|
-
var reactIs_production_min_17 = reactIs_production_min.
|
|
143
|
-
var reactIs_production_min_18 = reactIs_production_min.
|
|
144
|
-
var reactIs_production_min_19 = reactIs_production_min.
|
|
145
|
-
var reactIs_production_min_20 = reactIs_production_min.
|
|
128
|
+
var reactIs_production_min_3 = reactIs_production_min.ConcurrentMode;
|
|
129
|
+
var reactIs_production_min_4 = reactIs_production_min.ContextConsumer;
|
|
130
|
+
var reactIs_production_min_5 = reactIs_production_min.ContextProvider;
|
|
131
|
+
var reactIs_production_min_6 = reactIs_production_min.Element;
|
|
132
|
+
var reactIs_production_min_7 = reactIs_production_min.ForwardRef;
|
|
133
|
+
var reactIs_production_min_8 = reactIs_production_min.Fragment;
|
|
134
|
+
var reactIs_production_min_9 = reactIs_production_min.Profiler;
|
|
135
|
+
var reactIs_production_min_10 = reactIs_production_min.Portal;
|
|
136
|
+
var reactIs_production_min_11 = reactIs_production_min.StrictMode;
|
|
137
|
+
var reactIs_production_min_12 = reactIs_production_min.isValidElementType;
|
|
138
|
+
var reactIs_production_min_13 = reactIs_production_min.isAsyncMode;
|
|
139
|
+
var reactIs_production_min_14 = reactIs_production_min.isConcurrentMode;
|
|
140
|
+
var reactIs_production_min_15 = reactIs_production_min.isContextConsumer;
|
|
141
|
+
var reactIs_production_min_16 = reactIs_production_min.isContextProvider;
|
|
142
|
+
var reactIs_production_min_17 = reactIs_production_min.isElement;
|
|
143
|
+
var reactIs_production_min_18 = reactIs_production_min.isForwardRef;
|
|
144
|
+
var reactIs_production_min_19 = reactIs_production_min.isFragment;
|
|
145
|
+
var reactIs_production_min_20 = reactIs_production_min.isProfiler;
|
|
146
|
+
var reactIs_production_min_21 = reactIs_production_min.isPortal;
|
|
147
|
+
var reactIs_production_min_22 = reactIs_production_min.isStrictMode;
|
|
146
148
|
|
|
147
149
|
var reactIs = createCommonjsModule(function (module) {
|
|
148
150
|
|
|
@@ -151,22 +153,19 @@
|
|
|
151
153
|
}
|
|
152
154
|
});
|
|
153
155
|
|
|
154
|
-
var _ReactIs$ForwardRef;
|
|
155
|
-
|
|
156
|
-
function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
157
|
-
|
|
158
156
|
/**
|
|
159
157
|
* Copyright 2015, Yahoo! Inc.
|
|
160
158
|
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
161
159
|
*/
|
|
162
160
|
|
|
163
|
-
|
|
164
161
|
var REACT_STATICS = {
|
|
165
162
|
childContextTypes: true,
|
|
163
|
+
contextType: true,
|
|
166
164
|
contextTypes: true,
|
|
167
165
|
defaultProps: true,
|
|
168
166
|
displayName: true,
|
|
169
167
|
getDefaultProps: true,
|
|
168
|
+
getDerivedStateFromError: true,
|
|
170
169
|
getDerivedStateFromProps: true,
|
|
171
170
|
mixins: true,
|
|
172
171
|
propTypes: true,
|
|
@@ -183,7 +182,16 @@
|
|
|
183
182
|
arity: true
|
|
184
183
|
};
|
|
185
184
|
|
|
186
|
-
var
|
|
185
|
+
var FORWARD_REF_STATICS = {
|
|
186
|
+
'$$typeof': true,
|
|
187
|
+
render: true,
|
|
188
|
+
defaultProps: true,
|
|
189
|
+
displayName: true,
|
|
190
|
+
propTypes: true
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
var TYPE_STATICS = {};
|
|
194
|
+
TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
|
|
187
195
|
|
|
188
196
|
var defineProperty = Object.defineProperty;
|
|
189
197
|
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
|
@@ -567,8 +575,8 @@
|
|
|
567
575
|
configurable: true,
|
|
568
576
|
enumerable: true
|
|
569
577
|
}
|
|
570
|
-
/**
|
|
571
|
-
* Store Injection
|
|
578
|
+
/**
|
|
579
|
+
* Store Injection
|
|
572
580
|
*/
|
|
573
581
|
|
|
574
582
|
};
|
|
@@ -652,11 +660,11 @@
|
|
|
652
660
|
return nextProps;
|
|
653
661
|
};
|
|
654
662
|
}
|
|
655
|
-
/**
|
|
656
|
-
* higher order component that injects stores to a child.
|
|
657
|
-
* takes either a varargs list of strings, which are stores read from the context,
|
|
658
|
-
* or a function that manually maps the available stores from the context to props:
|
|
659
|
-
* storesToProps(mobxStores, props, context) => newProps
|
|
663
|
+
/**
|
|
664
|
+
* higher order component that injects stores to a child.
|
|
665
|
+
* takes either a varargs list of strings, which are stores read from the context,
|
|
666
|
+
* or a function that manually maps the available stores from the context to props:
|
|
667
|
+
* storesToProps(mobxStores, props, context) => newProps
|
|
660
668
|
*/
|
|
661
669
|
|
|
662
670
|
|
|
@@ -694,8 +702,8 @@
|
|
|
694
702
|
|
|
695
703
|
var mobxAdminProperty = mobx.$mobx || "$mobx";
|
|
696
704
|
var mobxIsUnmounted = newSymbol("isUnmounted");
|
|
697
|
-
/**
|
|
698
|
-
* dev tool support
|
|
705
|
+
/**
|
|
706
|
+
* dev tool support
|
|
699
707
|
*/
|
|
700
708
|
|
|
701
709
|
var isDevtoolsEnabled = false;
|
|
@@ -705,12 +713,14 @@
|
|
|
705
713
|
var componentByNodeRegistry = typeof WeakMap !== "undefined" ? new WeakMap() : undefined;
|
|
706
714
|
var renderReporter = new EventEmitter();
|
|
707
715
|
var skipRenderKey = newSymbol("skipRender");
|
|
708
|
-
var isForcingUpdateKey = newSymbol("isForcingUpdate");
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
*
|
|
713
|
-
* @param
|
|
716
|
+
var isForcingUpdateKey = newSymbol("isForcingUpdate"); // Using react-is had some issues (and operates on elements, not on types), see #608 / #609
|
|
717
|
+
|
|
718
|
+
var ReactForwardRefSymbol = typeof React.forwardRef === "function" && React.forwardRef(function (_props, _ref) {})["$$typeof"];
|
|
719
|
+
/**
|
|
720
|
+
* Helper to set `prop` to `this` as non-enumerable (hidden prop)
|
|
721
|
+
* @param target
|
|
722
|
+
* @param prop
|
|
723
|
+
* @param value
|
|
714
724
|
*/
|
|
715
725
|
|
|
716
726
|
function setHiddenProp(target, prop, value) {
|
|
@@ -750,13 +760,13 @@
|
|
|
750
760
|
function useStaticRendering(useStaticRendering) {
|
|
751
761
|
isUsingStaticRendering = useStaticRendering;
|
|
752
762
|
}
|
|
753
|
-
/**
|
|
754
|
-
* Errors reporter
|
|
763
|
+
/**
|
|
764
|
+
* Errors reporter
|
|
755
765
|
*/
|
|
756
766
|
|
|
757
767
|
var errorsReporter = new EventEmitter();
|
|
758
|
-
/**
|
|
759
|
-
* Utilities
|
|
768
|
+
/**
|
|
769
|
+
* Utilities
|
|
760
770
|
*/
|
|
761
771
|
|
|
762
772
|
function patch$1(target, funcName) {
|
|
@@ -831,15 +841,15 @@
|
|
|
831
841
|
|
|
832
842
|
var initialName = this.displayName || this.name || this.constructor && (this.constructor.displayName || this.constructor.name) || "<component>";
|
|
833
843
|
var rootNodeID = this._reactInternalInstance && this._reactInternalInstance._rootNodeID || this._reactInternalInstance && this._reactInternalInstance._debugID || this._reactInternalFiber && this._reactInternalFiber._debugID;
|
|
834
|
-
/**
|
|
835
|
-
* If props are shallowly modified, react will render anyway,
|
|
836
|
-
* so atom.reportChanged() should not result in yet another re-render
|
|
844
|
+
/**
|
|
845
|
+
* If props are shallowly modified, react will render anyway,
|
|
846
|
+
* so atom.reportChanged() should not result in yet another re-render
|
|
837
847
|
*/
|
|
838
848
|
|
|
839
849
|
setHiddenProp(this, skipRenderKey, false);
|
|
840
|
-
/**
|
|
841
|
-
* forceUpdate will re-assign this.props. We don't want that to cause a loop,
|
|
842
|
-
* so detect these changes
|
|
850
|
+
/**
|
|
851
|
+
* forceUpdate will re-assign this.props. We don't want that to cause a loop,
|
|
852
|
+
* so detect these changes
|
|
843
853
|
*/
|
|
844
854
|
|
|
845
855
|
setHiddenProp(this, isForcingUpdateKey, false); // wire up reactive render
|
|
@@ -857,7 +867,7 @@
|
|
|
857
867
|
if (_this2[mobxIsUnmounted] !== true) {
|
|
858
868
|
// If we are unmounted at this point, componentWillReact() had a side effect causing the component to unmounted
|
|
859
869
|
// TODO: remove this check? Then react will properly warn about the fact that this should not happen? See #73
|
|
860
|
-
// However, people also claim this
|
|
870
|
+
// However, people also claim this might happen during unit tests..
|
|
861
871
|
var hasError = true;
|
|
862
872
|
|
|
863
873
|
try {
|
|
@@ -876,8 +886,8 @@
|
|
|
876
886
|
this.render = reactiveRender;
|
|
877
887
|
return reactiveRender.call(this);
|
|
878
888
|
}
|
|
879
|
-
/**
|
|
880
|
-
* ReactiveMixin
|
|
889
|
+
/**
|
|
890
|
+
* ReactiveMixin
|
|
881
891
|
*/
|
|
882
892
|
|
|
883
893
|
|
|
@@ -960,8 +970,8 @@
|
|
|
960
970
|
}
|
|
961
971
|
});
|
|
962
972
|
}
|
|
963
|
-
/**
|
|
964
|
-
* Observer function / decorator
|
|
973
|
+
/**
|
|
974
|
+
* Observer function / decorator
|
|
965
975
|
*/
|
|
966
976
|
|
|
967
977
|
|
|
@@ -996,6 +1006,21 @@
|
|
|
996
1006
|
|
|
997
1007
|
if (componentClass.__proto__ === React.PureComponent) {
|
|
998
1008
|
console.warn("Mobx observer: You are using 'observer' on React.PureComponent. These two achieve two opposite goals and should not be used together");
|
|
1009
|
+
} // Unwrap forward refs into `<Observer>` component
|
|
1010
|
+
// we need to unwrap the render, because it is the inner render that needs to be tracked,
|
|
1011
|
+
// not the ForwardRef HoC
|
|
1012
|
+
|
|
1013
|
+
|
|
1014
|
+
if (ReactForwardRefSymbol && componentClass["$$typeof"] === ReactForwardRefSymbol) {
|
|
1015
|
+
var _baseRender = componentClass.render;
|
|
1016
|
+
if (typeof _baseRender !== "function") throw new Error("render property of ForwardRef was not a function"); // TODO: do we need to hoist statics from baseRender to the forward ref?
|
|
1017
|
+
|
|
1018
|
+
return React.forwardRef(function ObserverForwardRef() {
|
|
1019
|
+
var _arguments = arguments;
|
|
1020
|
+
return React__default.createElement(Observer, null, function () {
|
|
1021
|
+
return _baseRender.apply(undefined, _arguments);
|
|
1022
|
+
});
|
|
1023
|
+
});
|
|
999
1024
|
} // Stateless function component:
|
|
1000
1025
|
// If it is function but doesn't seem to be a react class constructor,
|
|
1001
1026
|
// wrap it to a react class automatically
|
|
@@ -1061,10 +1086,10 @@
|
|
|
1061
1086
|
}
|
|
1062
1087
|
}
|
|
1063
1088
|
|
|
1064
|
-
var Observer = observer(function (
|
|
1065
|
-
var children =
|
|
1066
|
-
observerInject =
|
|
1067
|
-
render =
|
|
1089
|
+
var Observer = observer(function (_ref2) {
|
|
1090
|
+
var children = _ref2.children,
|
|
1091
|
+
observerInject = _ref2.inject,
|
|
1092
|
+
render = _ref2.render;
|
|
1068
1093
|
var component = children || render;
|
|
1069
1094
|
|
|
1070
1095
|
if (typeof component === "undefined") {
|