|
1 | | -import { BaseApp, EventType, Overmind, Configuration } from 'overmind' |
2 | | -import * as React from 'react' |
| 1 | +import { BaseApp, Configuration, EventType, Overmind } from 'overmind' |
3 | 2 | import { |
| 3 | + // @ts-ignore |
| 4 | + __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, |
| 5 | + ClassicComponentClass, |
| 6 | + ComponentClass, |
| 7 | + createElement, |
| 8 | + PureComponent, |
| 9 | + StatelessComponent, |
4 | 10 | // @ts-ignore |
5 | 11 | useEffect, |
6 | 12 | // @ts-ignore |
7 | 13 | useState, |
8 | | - // @ts-ignore |
9 | | - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, |
10 | 14 | } from 'react' |
11 | 15 |
|
12 | 16 | export type IReactComponent<P = any> = |
13 | | - | React.StatelessComponent<P> |
14 | | - | React.ComponentClass<P> |
15 | | - | React.ClassicComponentClass<P> |
| 17 | + | StatelessComponent<P> |
| 18 | + | ComponentClass<P> |
| 19 | + | ClassicComponentClass<P> |
16 | 20 |
|
17 | 21 | // Diff / Omit taken from https://github.com/Microsoft/TypeScript/issues/12215#issuecomment-311923766 |
18 | 22 | type Omit<T, K extends keyof T> = Pick< |
@@ -182,15 +186,15 @@ export const createConnect = <App extends Overmind<Configuration>>( |
182 | 186 | } |
183 | 187 | } |
184 | 188 |
|
185 | | - const klass = class extends React.PureComponent< |
| 189 | + const klass = class extends PureComponent< |
186 | 190 | Omit<Props & TConnect<App>, keyof TConnect<App>> |
187 | 191 | > { |
188 | 192 | __mutationListener: any |
189 | 193 | __isUnmounting: boolean |
190 | 194 | __componentId: number |
191 | 195 | __componentInstanceId = componentInstanceId++ |
192 | 196 | __reactionFactory = app.createReactionFactory( |
193 | | - Component.name || Component.displayName |
| 197 | + Component.name || Component.displayName || 'Component' |
194 | 198 | ) |
195 | 199 | componentWillUnmount() { |
196 | 200 | this.__isUnmounting = true |
@@ -255,7 +259,7 @@ export const createConnect = <App extends Overmind<Configuration>>( |
255 | 259 | return value |
256 | 260 | } |
257 | 261 | renderClassComponent() { |
258 | | - return React.createElement(Component, Object.assign({}, this.props, { |
| 262 | + return createElement(Component, Object.assign({}, this.props, { |
259 | 263 | app: { |
260 | 264 | state: app.state, |
261 | 265 | actions: app.actions, |
|
0 commit comments