Skip to content

Commit 645faac

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

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

src/drivers/react.js

+13-10
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,26 @@ 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+
type Class<T> = { new(): T };
1420

1521
type ReactElementType = {|
1622

1723
|};
1824

1925
type ReactType = {|
20-
Component : __ReactComponent,
26+
Component : typeof __ReactComponent,
2127
createClass : ({| render : () => ReactElementType, componentDidMount : () => void, componentDidUpdate : () => void |}) => (typeof ReactClassType),
2228
createElement : (string, ?{ [string] : mixed }, ...children : $ReadOnlyArray<ReactElementType>) => ReactElementType
2329
|};
2430

2531
type ReactDomType = {|
26-
findDOMNode : (typeof ReactClassType) => HTMLElement
32+
findDOMNode : (__ReactComponent) => HTMLElement
2733
|};
2834

2935
type ReactLibraryType = {|
@@ -35,7 +41,7 @@ type ReactLibraryType = {|
3541
/**
3642
* Util to check if component is currently mounted
3743
*/
38-
function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) : boolean {
44+
function isMounted(component : __ReactComponent, ReactDOM : ReactDomType) : boolean {
3945
try {
4046
return Boolean(ReactDOM.findDOMNode(component));
4147
}
@@ -45,19 +51,16 @@ function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) :
4551
}
4652
}
4753

54+
export const react : ComponentDriverType<*, ReactLibraryType, Class<__ReactComponent>> = {
4855

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

53-
// $FlowFixMe
54-
return class extends React.Component {
58+
return class ZoidReactComponent extends React.Component {
5559
render() : ReactElementType {
5660
return React.createElement('div', null);
5761
}
5862

5963
componentDidMount() {
60-
// $FlowFixMe
6164
const el = ReactDOM.findDOMNode(this);
6265
const parent = init(extend({}, this.props));
6366
parent.render(el, CONTEXT.IFRAME)

0 commit comments

Comments
 (0)