Skip to content

Commit 06ef90e

Browse files
committed
fix(react): fix all 'react' driver flow / lint errors.
1 parent 3d698b8 commit 06ef90e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/drivers/react.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,27 @@ import { CONTEXT } from '../constants';
1010
declare class ReactClassType {}
1111

1212
// eslint-disable-next-line flowtype/require-exact-type
13-
declare class __ReactComponent {}
13+
declare class __ReactComponent {
14+
state : mixed,
15+
props : mixed,
16+
setState : (newStateOrFn : mixed) => void
17+
}
18+
19+
// eslint-disable-next-line flowtype/require-exact-type
20+
type Class<T> = { new(): T };
1421

1522
type ReactElementType = {|
1623

1724
|};
1825

1926
type ReactType = {|
20-
Component : __ReactComponent,
27+
Component : typeof __ReactComponent,
2128
createClass : ({| render : () => ReactElementType, componentDidMount : () => void, componentDidUpdate : () => void |}) => (typeof ReactClassType),
2229
createElement : (string, ?{ [string] : mixed }, ...children : $ReadOnlyArray<ReactElementType>) => ReactElementType
2330
|};
2431

2532
type ReactDomType = {|
26-
findDOMNode : (typeof ReactClassType) => HTMLElement
33+
findDOMNode : (__ReactComponent) => HTMLElement
2734
|};
2835

2936
type ReactLibraryType = {|
@@ -35,7 +42,7 @@ type ReactLibraryType = {|
3542
/**
3643
* Util to check if component is currently mounted
3744
*/
38-
function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) : boolean {
45+
function isMounted(component : __ReactComponent, ReactDOM : ReactDomType) : boolean {
3946
try {
4047
return Boolean(ReactDOM.findDOMNode(component));
4148
}
@@ -45,19 +52,16 @@ function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) :
4552
}
4653
}
4754

55+
export const react : ComponentDriverType<*, ReactLibraryType, Class<__ReactComponent>> = {
4856

49-
export const react : ComponentDriverType<*, ReactLibraryType, typeof ReactClassType> = {
50-
51-
register: (tag, propsDef, init, { React, ReactDOM }) => {
57+
register: (tag, propsDef, init, { React, ReactDOM }) : Class<__ReactComponent> => {
5258

53-
// $FlowFixMe
54-
return class extends React.Component {
59+
return class ZoidReactComponent extends React.Component {
5560
render() : ReactElementType {
5661
return React.createElement('div', null);
5762
}
5863

5964
componentDidMount() {
60-
// $FlowFixMe
6165
const el = ReactDOM.findDOMNode(this);
6266
const parent = init(extend({}, this.props));
6367
parent.render(el, CONTEXT.IFRAME)

0 commit comments

Comments
 (0)