mobx-react 9.2.1 → 10.0.0

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 (41) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +8 -264
  3. package/dist/index.d.ts +1 -6
  4. package/dist/mobxreact.cjs.development.js +101 -449
  5. package/dist/mobxreact.cjs.development.js.map +1 -1
  6. package/dist/mobxreact.cjs.production.min.js +1 -1
  7. package/dist/mobxreact.cjs.production.min.js.map +1 -1
  8. package/dist/mobxreact.esm.development.js +76 -405
  9. package/dist/mobxreact.esm.development.js.map +1 -1
  10. package/dist/mobxreact.esm.js +75 -404
  11. package/dist/mobxreact.esm.js.map +1 -1
  12. package/dist/mobxreact.esm.production.min.js +1 -1
  13. package/dist/mobxreact.esm.production.min.js.map +1 -1
  14. package/dist/mobxreact.mjs +338 -0
  15. package/dist/mobxreact.mjs.map +1 -0
  16. package/dist/mobxreact.umd.development.js +103 -450
  17. package/dist/mobxreact.umd.development.js.map +1 -1
  18. package/dist/mobxreact.umd.production.min.js +1 -1
  19. package/dist/mobxreact.umd.production.min.js.map +1 -1
  20. package/dist/utils/utils.d.ts +0 -8
  21. package/package.json +32 -22
  22. package/src/index.ts +3 -12
  23. package/src/observer.tsx +9 -8
  24. package/src/utils/utils.ts +0 -46
  25. package/batchingForReactDom.js +0 -1
  26. package/batchingForReactNative.js +0 -1
  27. package/batchingOptOut.js +0 -1
  28. package/dist/Provider.d.ts +0 -10
  29. package/dist/disposeOnUnmount.d.ts +0 -11
  30. package/dist/inject.d.ts +0 -6
  31. package/dist/propTypes.d.ts +0 -9
  32. package/dist/types/IStoresToProps.d.ts +0 -2
  33. package/dist/types/IValueMap.d.ts +0 -1
  34. package/dist/types/IWrappedComponent.d.ts +0 -4
  35. package/src/Provider.tsx +0 -29
  36. package/src/disposeOnUnmount.ts +0 -111
  37. package/src/inject.ts +0 -107
  38. package/src/propTypes.ts +0 -210
  39. package/src/types/IStoresToProps.ts +0 -7
  40. package/src/types/IValueMap.ts +0 -1
  41. package/src/types/IWrappedComponent.ts +0 -4
package/src/observer.tsx CHANGED
@@ -7,17 +7,18 @@ import { IReactComponent } from "./types/IReactComponent"
7
7
  /**
8
8
  * Observer function / decorator
9
9
  */
10
- export function observer<T extends IReactComponent>(component: T, context: ClassDecoratorContext): void
10
+ export function observer<T extends IReactComponent>(
11
+ component: T,
12
+ context: ClassDecoratorContext
13
+ ): void
11
14
  export function observer<T extends IReactComponent>(component: T): T
12
- export function observer<T extends IReactComponent>(component: T, context?: ClassDecoratorContext): T {
15
+ export function observer<T extends IReactComponent>(
16
+ component: T,
17
+ context?: ClassDecoratorContext
18
+ ): T {
13
19
  if (context && context.kind !== "class") {
14
20
  throw new Error("The @observer decorator can be used on classes only")
15
21
  }
16
- if (component["isMobxInjector"] === true) {
17
- console.warn(
18
- "Mobx observer: You are trying to use `observer` on a component that already has `inject`. Please apply `observer` before applying `inject`"
19
- )
20
- }
21
22
 
22
23
  if (
23
24
  Object.prototype.isPrototypeOf.call(React.Component, component) ||
@@ -27,6 +28,6 @@ export function observer<T extends IReactComponent>(component: T, context?: Clas
27
28
  return makeClassComponentObserver(component as React.ComponentClass<any, any>) as T
28
29
  } else {
29
30
  // Function component
30
- return observerLite(component as React.FunctionComponent<any>) as T
31
+ return observerLite(component as React.FunctionComponent<any>) as unknown as T
31
32
  }
32
33
  }
@@ -28,52 +28,6 @@ function is(x: any, y: any): boolean {
28
28
  }
29
29
  }
30
30
 
31
- // based on https://github.com/mridgway/hoist-non-react-statics/blob/master/src/index.js
32
- const hoistBlackList = {
33
- $$typeof: 1,
34
- render: 1,
35
- compare: 1,
36
- type: 1,
37
- childContextTypes: 1,
38
- contextType: 1,
39
- contextTypes: 1,
40
- defaultProps: 1,
41
- getDefaultProps: 1,
42
- getDerivedStateFromError: 1,
43
- getDerivedStateFromProps: 1,
44
- mixins: 1,
45
- displayName: 1,
46
- propTypes: 1
47
- }
48
-
49
- export function copyStaticProperties(base: object, target: object): void {
50
- const protoProps = Object.getOwnPropertyNames(Object.getPrototypeOf(base))
51
- Object.getOwnPropertyNames(base).forEach(key => {
52
- if (!hoistBlackList[key] && protoProps.indexOf(key) === -1) {
53
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(base, key)!)
54
- }
55
- })
56
- }
57
-
58
- /**
59
- * Helper to set `prop` to `this` as non-enumerable (hidden prop)
60
- * @param target
61
- * @param prop
62
- * @param value
63
- */
64
- export function setHiddenProp(target: object, prop: any, value: any): void {
65
- if (!Object.hasOwnProperty.call(target, prop)) {
66
- Object.defineProperty(target, prop, {
67
- enumerable: false,
68
- configurable: true,
69
- writable: true,
70
- value
71
- })
72
- } else {
73
- target[prop] = value
74
- }
75
- }
76
-
77
31
  /**
78
32
  * Utilities for patching componentWillUnmount, to make sure @disposeOnUnmount works correctly icm with user defined hooks
79
33
  * and the handler provided by mobx-react
@@ -1 +0,0 @@
1
- require("mobx-react-lite/batchingForReactDom")
@@ -1 +0,0 @@
1
- require("mobx-react-lite/batchingForReactNative")
package/batchingOptOut.js DELETED
@@ -1 +0,0 @@
1
- require("mobx-react-lite/batchingOptOut")
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { IValueMap } from "./types/IValueMap";
3
- export declare const MobXProviderContext: React.Context<IValueMap>;
4
- export interface ProviderProps extends IValueMap {
5
- children: React.ReactNode;
6
- }
7
- export declare function Provider(props: ProviderProps): React.JSX.Element;
8
- export declare namespace Provider {
9
- var displayName: string;
10
- }
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- type Disposer = () => void;
3
- /**
4
- * @deprecated `disposeOnUnmount` is not compatible with React 18 and higher.
5
- */
6
- export declare function disposeOnUnmount(target: React.Component<any, any>, propertyKey: PropertyKey): void;
7
- /**
8
- * @deprecated `disposeOnUnmount` is not compatible with React 18 and higher.
9
- */
10
- export declare function disposeOnUnmount<TF extends Disposer | Array<Disposer>>(target: React.Component<any, any>, fn: TF): TF;
11
- export {};
package/dist/inject.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { IReactComponent } from "./types/IReactComponent";
2
- import { IValueMap } from "./types/IValueMap";
3
- import { IWrappedComponent } from "./types/IWrappedComponent";
4
- import { IStoresToProps } from "./types/IStoresToProps";
5
- export declare function inject(...stores: Array<string>): <T extends IReactComponent<any>>(target: T) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never);
6
- export declare function inject<S extends IValueMap = {}, P extends IValueMap = {}, I extends IValueMap = {}, C extends IValueMap = {}>(fn: IStoresToProps<S, P, I, C>): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>;
@@ -1,9 +0,0 @@
1
- export declare const PropTypes: {
2
- observableArray: import("react").Requireable<any>;
3
- observableArrayOf: (typeChecker: import("react").Validator<any>) => import("react").Requireable<any>;
4
- observableMap: import("react").Requireable<any>;
5
- observableObject: import("react").Requireable<any>;
6
- arrayOrObservableArray: import("react").Requireable<any>;
7
- arrayOrObservableArrayOf: (typeChecker: import("react").Validator<any>) => import("react").Requireable<any>;
8
- objectOrObservableObject: import("react").Requireable<any>;
9
- };
@@ -1,2 +0,0 @@
1
- import { IValueMap } from "./IValueMap";
2
- export type IStoresToProps<S extends IValueMap = {}, P extends IValueMap = {}, I extends IValueMap = {}, C extends IValueMap = {}> = (stores: S, nextProps: P, context?: C) => I;
@@ -1 +0,0 @@
1
- export type IValueMap = Record<string, any>;
@@ -1,4 +0,0 @@
1
- import { IReactComponent } from "./IReactComponent";
2
- export type IWrappedComponent<P> = {
3
- wrappedComponent: IReactComponent<P>;
4
- };
package/src/Provider.tsx DELETED
@@ -1,29 +0,0 @@
1
- import React from "react"
2
- import { shallowEqual } from "./utils/utils"
3
- import { IValueMap } from "./types/IValueMap"
4
-
5
- export const MobXProviderContext = React.createContext<IValueMap>({})
6
-
7
- export interface ProviderProps extends IValueMap {
8
- children: React.ReactNode
9
- }
10
-
11
- export function Provider(props: ProviderProps) {
12
- const { children, ...stores } = props
13
- const parentValue = React.useContext(MobXProviderContext)
14
- const mutableProviderRef = React.useRef({ ...parentValue, ...stores })
15
- const value = mutableProviderRef.current
16
-
17
- if (__DEV__) {
18
- const newValue = { ...value, ...stores } // spread in previous state for the context based stores
19
- if (!shallowEqual(value, newValue)) {
20
- throw new Error(
21
- "MobX Provider: The set of provided stores has changed. See: https://github.com/mobxjs/mobx-react#the-set-of-provided-stores-has-changed-error."
22
- )
23
- }
24
- }
25
-
26
- return <MobXProviderContext.Provider value={value}>{children}</MobXProviderContext.Provider>
27
- }
28
-
29
- Provider.displayName = "MobXProvider"
@@ -1,111 +0,0 @@
1
- import React from "react"
2
- import { patch } from "./utils/utils"
3
-
4
- const reactMajorVersion = Number.parseInt(React.version.split(".")[0])
5
- let warnedAboutDisposeOnUnmountDeprecated = false
6
-
7
- type Disposer = () => void
8
-
9
- const protoStoreKey = Symbol("disposeOnUnmountProto")
10
- const instStoreKey = Symbol("disposeOnUnmountInst")
11
-
12
- function runDisposersOnWillUnmount() {
13
- ;[...(this[protoStoreKey] || []), ...(this[instStoreKey] || [])].forEach(propKeyOrFunction => {
14
- const prop =
15
- typeof propKeyOrFunction === "string" ? this[propKeyOrFunction] : propKeyOrFunction
16
- if (prop !== undefined && prop !== null) {
17
- if (Array.isArray(prop)) prop.map(f => f())
18
- else prop()
19
- }
20
- })
21
- }
22
-
23
- /**
24
- * @deprecated `disposeOnUnmount` is not compatible with React 18 and higher.
25
- */
26
- export function disposeOnUnmount(target: React.Component<any, any>, propertyKey: PropertyKey): void
27
-
28
- /**
29
- * @deprecated `disposeOnUnmount` is not compatible with React 18 and higher.
30
- */
31
- export function disposeOnUnmount<TF extends Disposer | Array<Disposer>>(
32
- target: React.Component<any, any>,
33
- fn: TF
34
- ): TF
35
-
36
- /**
37
- * @deprecated `disposeOnUnmount` is not compatible with React 18 and higher.
38
- */
39
- export function disposeOnUnmount(
40
- target: React.Component<any, any>,
41
- propertyKeyOrFunction: PropertyKey | Disposer | Array<Disposer>
42
- ): PropertyKey | Disposer | Array<Disposer> | void {
43
- if (Array.isArray(propertyKeyOrFunction)) {
44
- return propertyKeyOrFunction.map(fn => disposeOnUnmount(target, fn))
45
- }
46
-
47
- if (!warnedAboutDisposeOnUnmountDeprecated) {
48
- if (reactMajorVersion >= 18) {
49
- console.error(
50
- "[mobx-react] disposeOnUnmount is not compatible with React 18 and higher. Don't use it."
51
- )
52
- } else {
53
- console.warn(
54
- "[mobx-react] disposeOnUnmount is deprecated. It won't work correctly with React 18 and higher."
55
- )
56
- }
57
- warnedAboutDisposeOnUnmountDeprecated = true
58
- }
59
-
60
- const c = Object.getPrototypeOf(target).constructor
61
- const c2 = Object.getPrototypeOf(target.constructor)
62
- // Special case for react-hot-loader
63
- const c3 = Object.getPrototypeOf(Object.getPrototypeOf(target))
64
- if (
65
- !(
66
- c === React.Component ||
67
- c === React.PureComponent ||
68
- c2 === React.Component ||
69
- c2 === React.PureComponent ||
70
- c3 === React.Component ||
71
- c3 === React.PureComponent
72
- )
73
- ) {
74
- throw new Error(
75
- "[mobx-react] disposeOnUnmount only supports direct subclasses of React.Component or React.PureComponent."
76
- )
77
- }
78
-
79
- if (
80
- typeof propertyKeyOrFunction !== "string" &&
81
- typeof propertyKeyOrFunction !== "function" &&
82
- !Array.isArray(propertyKeyOrFunction)
83
- ) {
84
- throw new Error(
85
- "[mobx-react] disposeOnUnmount only works if the parameter is either a property key or a function."
86
- )
87
- }
88
-
89
- // decorator's target is the prototype, so it doesn't have any instance properties like props
90
- const isDecorator = typeof propertyKeyOrFunction === "string"
91
-
92
- // add property key / function we want run (disposed) to the store
93
- const componentWasAlreadyModified = !!target[protoStoreKey] || !!target[instStoreKey]
94
- const store = isDecorator
95
- ? // decorators are added to the prototype store
96
- target[protoStoreKey] || (target[protoStoreKey] = [])
97
- : // functions are added to the instance store
98
- target[instStoreKey] || (target[instStoreKey] = [])
99
-
100
- store.push(propertyKeyOrFunction)
101
-
102
- // tweak the component class componentWillUnmount if not done already
103
- if (!componentWasAlreadyModified) {
104
- patch(target, "componentWillUnmount", runDisposersOnWillUnmount)
105
- }
106
-
107
- // return the disposer as is if invoked as a non decorator
108
- if (typeof propertyKeyOrFunction !== "string") {
109
- return propertyKeyOrFunction
110
- }
111
- }
package/src/inject.ts DELETED
@@ -1,107 +0,0 @@
1
- import React from "react"
2
- import { observer } from "./observer"
3
- import { copyStaticProperties } from "./utils/utils"
4
- import { MobXProviderContext } from "./Provider"
5
- import { IReactComponent } from "./types/IReactComponent"
6
- import { IValueMap } from "./types/IValueMap"
7
- import { IWrappedComponent } from "./types/IWrappedComponent"
8
- import { IStoresToProps } from "./types/IStoresToProps"
9
-
10
- /**
11
- * Store Injection
12
- */
13
- function createStoreInjector(
14
- grabStoresFn: IStoresToProps,
15
- component: IReactComponent<any>,
16
- injectNames: string,
17
- makeReactive: boolean
18
- ): IReactComponent<any> {
19
- // Support forward refs
20
- let Injector: IReactComponent<any> = React.forwardRef((props, ref) => {
21
- const newProps = { ...props }
22
- const context = React.useContext(MobXProviderContext)
23
- Object.assign(newProps, grabStoresFn(context || {}, newProps) || {})
24
-
25
- if (ref) {
26
- newProps.ref = ref
27
- }
28
-
29
- return React.createElement(component, newProps)
30
- })
31
-
32
- if (makeReactive) Injector = observer(Injector)
33
- Injector["isMobxInjector"] = true // assigned late to suppress observer warning
34
-
35
- // Static fields from component should be visible on the generated Injector
36
- copyStaticProperties(component, Injector)
37
- Injector["wrappedComponent"] = component
38
- Injector.displayName = getInjectName(component, injectNames)
39
- return Injector
40
- }
41
-
42
- function getInjectName(component: IReactComponent<any>, injectNames: string): string {
43
- let displayName
44
- const componentName =
45
- component.displayName ||
46
- component.name ||
47
- (component.constructor && component.constructor.name) ||
48
- "Component"
49
- if (injectNames) displayName = "inject-with-" + injectNames + "(" + componentName + ")"
50
- else displayName = "inject(" + componentName + ")"
51
- return displayName
52
- }
53
-
54
- function grabStoresByName(
55
- storeNames: Array<string>
56
- ): (
57
- baseStores: IValueMap,
58
- nextProps: React.ClassAttributes<any>
59
- ) => React.PropsWithRef<any> | undefined {
60
- return function (baseStores, nextProps) {
61
- storeNames.forEach(function (storeName) {
62
- if (
63
- storeName in nextProps // prefer props over stores
64
- )
65
- return
66
- if (!(storeName in baseStores))
67
- throw new Error(
68
- "MobX injector: Store '" +
69
- storeName +
70
- "' is not available! Make sure it is provided by some Provider"
71
- )
72
- nextProps[storeName] = baseStores[storeName]
73
- })
74
- return nextProps
75
- }
76
- }
77
-
78
- export function inject(
79
- ...stores: Array<string>
80
- ): <T extends IReactComponent<any>>(
81
- target: T
82
- ) => T & (T extends IReactComponent<infer P> ? IWrappedComponent<P> : never)
83
- export function inject<S extends IValueMap = {}, P extends IValueMap = {}, I extends IValueMap = {}, C extends IValueMap = {}>(
84
- fn: IStoresToProps<S, P, I, C>
85
- ): <T extends IReactComponent>(target: T) => T & IWrappedComponent<P>
86
-
87
- /**
88
- * higher order component that injects stores to a child.
89
- * takes either a varargs list of strings, which are stores read from the context,
90
- * or a function that manually maps the available stores from the context to props:
91
- * storesToProps(mobxStores, props, context) => newProps
92
- */
93
- export function inject(/* fn(stores, nextProps) or ...storeNames */ ...storeNames: Array<any>) {
94
- if (typeof arguments[0] === "function") {
95
- let grabStoresFn = arguments[0]
96
- return (componentClass: React.ComponentClass<any, any>) =>
97
- createStoreInjector(grabStoresFn, componentClass, grabStoresFn.name, true)
98
- } else {
99
- return (componentClass: React.ComponentClass<any, any>) =>
100
- createStoreInjector(
101
- grabStoresByName(storeNames),
102
- componentClass,
103
- storeNames.join("-"),
104
- false
105
- )
106
- }
107
- }
package/src/propTypes.ts DELETED
@@ -1,210 +0,0 @@
1
- import { isObservableArray, isObservableObject, isObservableMap, untracked } from "mobx"
2
-
3
- // Copied from React.PropTypes
4
- function createChainableTypeChecker(validator: React.Validator<any>): React.Requireable<any> {
5
- function checkType(
6
- isRequired: boolean,
7
- props: any,
8
- propName: string,
9
- componentName: string,
10
- location: string,
11
- propFullName: string,
12
- ...rest: any[]
13
- ) {
14
- return untracked(() => {
15
- componentName = componentName || "<<anonymous>>"
16
- propFullName = propFullName || propName
17
- if (props[propName] == null) {
18
- if (isRequired) {
19
- const actual = props[propName] === null ? "null" : "undefined"
20
- return new Error(
21
- "The " +
22
- location +
23
- " `" +
24
- propFullName +
25
- "` is marked as required " +
26
- "in `" +
27
- componentName +
28
- "`, but its value is `" +
29
- actual +
30
- "`."
31
- )
32
- }
33
- return null
34
- } else {
35
- // @ts-ignore rest arg is necessary for some React internals - fails tests otherwise
36
- return validator(props, propName, componentName, location, propFullName, ...rest)
37
- }
38
- })
39
- }
40
-
41
- const chainedCheckType: any = checkType.bind(null, false)
42
- // Add isRequired to satisfy Requirable
43
- chainedCheckType.isRequired = checkType.bind(null, true)
44
- return chainedCheckType
45
- }
46
-
47
- // Copied from React.PropTypes
48
- function isSymbol(propType: any, propValue: any): boolean {
49
- // Native Symbol.
50
- if (propType === "symbol") {
51
- return true
52
- }
53
-
54
- // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
55
- if (propValue["@@toStringTag"] === "Symbol") {
56
- return true
57
- }
58
-
59
- // Fallback for non-spec compliant Symbols which are polyfilled.
60
- if (typeof Symbol === "function" && propValue instanceof Symbol) {
61
- return true
62
- }
63
-
64
- return false
65
- }
66
-
67
- // Copied from React.PropTypes
68
- function getPropType(propValue: any): string {
69
- const propType = typeof propValue
70
- if (Array.isArray(propValue)) {
71
- return "array"
72
- }
73
- if (propValue instanceof RegExp) {
74
- // Old webkits (at least until Android 4.0) return 'function' rather than
75
- // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
76
- // passes PropTypes.object.
77
- return "object"
78
- }
79
- if (isSymbol(propType, propValue)) {
80
- return "symbol"
81
- }
82
- return propType
83
- }
84
-
85
- // This handles more types than `getPropType`. Only used for error messages.
86
- // Copied from React.PropTypes
87
- function getPreciseType(propValue: any): string {
88
- const propType = getPropType(propValue)
89
- if (propType === "object") {
90
- if (propValue instanceof Date) {
91
- return "date"
92
- } else if (propValue instanceof RegExp) {
93
- return "regexp"
94
- }
95
- }
96
- return propType
97
- }
98
-
99
- function createObservableTypeCheckerCreator(
100
- allowNativeType: any,
101
- mobxType: any
102
- ): React.Requireable<any> {
103
- return createChainableTypeChecker((props, propName, componentName, location, propFullName) => {
104
- return untracked(() => {
105
- if (allowNativeType) {
106
- if (getPropType(props[propName]) === mobxType.toLowerCase()) return null
107
- }
108
- let mobxChecker
109
- switch (mobxType) {
110
- case "Array":
111
- mobxChecker = isObservableArray
112
- break
113
- case "Object":
114
- mobxChecker = isObservableObject
115
- break
116
- case "Map":
117
- mobxChecker = isObservableMap
118
- break
119
- default:
120
- throw new Error(`Unexpected mobxType: ${mobxType}`)
121
- }
122
- const propValue = props[propName]
123
- if (!mobxChecker(propValue)) {
124
- const preciseType = getPreciseType(propValue)
125
- const nativeTypeExpectationMessage = allowNativeType
126
- ? " or javascript `" + mobxType.toLowerCase() + "`"
127
- : ""
128
- return new Error(
129
- "Invalid prop `" +
130
- propFullName +
131
- "` of type `" +
132
- preciseType +
133
- "` supplied to" +
134
- " `" +
135
- componentName +
136
- "`, expected `mobx.Observable" +
137
- mobxType +
138
- "`" +
139
- nativeTypeExpectationMessage +
140
- "."
141
- )
142
- }
143
- return null
144
- })
145
- })
146
- }
147
-
148
- function createObservableArrayOfTypeChecker(
149
- allowNativeType: boolean,
150
- typeChecker: React.Validator<any>
151
- ) {
152
- return createChainableTypeChecker(
153
- (props, propName, componentName, location, propFullName, ...rest) => {
154
- return untracked(() => {
155
- if (typeof typeChecker !== "function") {
156
- return new Error(
157
- "Property `" +
158
- propFullName +
159
- "` of component `" +
160
- componentName +
161
- "` has " +
162
- "invalid PropType notation."
163
- )
164
- } else {
165
- let error = createObservableTypeCheckerCreator(allowNativeType, "Array")(
166
- props,
167
- propName,
168
- componentName,
169
- location,
170
- propFullName
171
- )
172
-
173
- if (error instanceof Error) return error
174
- const propValue = props[propName]
175
- for (let i = 0; i < propValue.length; i++) {
176
- error = (typeChecker as React.Validator<any>)(
177
- propValue,
178
- i as any,
179
- componentName,
180
- location,
181
- propFullName + "[" + i + "]",
182
- ...rest
183
- )
184
- if (error instanceof Error) return error
185
- }
186
-
187
- return null
188
- }
189
- })
190
- }
191
- )
192
- }
193
-
194
- const observableArray = createObservableTypeCheckerCreator(false, "Array")
195
- const observableArrayOf = createObservableArrayOfTypeChecker.bind(null, false)
196
- const observableMap = createObservableTypeCheckerCreator(false, "Map")
197
- const observableObject = createObservableTypeCheckerCreator(false, "Object")
198
- const arrayOrObservableArray = createObservableTypeCheckerCreator(true, "Array")
199
- const arrayOrObservableArrayOf = createObservableArrayOfTypeChecker.bind(null, true)
200
- const objectOrObservableObject = createObservableTypeCheckerCreator(true, "Object")
201
-
202
- export const PropTypes = {
203
- observableArray,
204
- observableArrayOf,
205
- observableMap,
206
- observableObject,
207
- arrayOrObservableArray,
208
- arrayOrObservableArrayOf,
209
- objectOrObservableObject
210
- }
@@ -1,7 +0,0 @@
1
- import { IValueMap } from "./IValueMap"
2
- export type IStoresToProps<
3
- S extends IValueMap = {},
4
- P extends IValueMap = {},
5
- I extends IValueMap = {},
6
- C extends IValueMap = {}
7
- > = (stores: S, nextProps: P, context?: C) => I
@@ -1 +0,0 @@
1
- export type IValueMap = Record<string, any>
@@ -1,4 +0,0 @@
1
- import { IReactComponent } from "./IReactComponent"
2
- export type IWrappedComponent<P> = {
3
- wrappedComponent: IReactComponent<P>
4
- }