Skip to content

Commit cf61b10

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

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/drivers/react.js

+15-10
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,33 @@ import { extend, noop } from 'belter/src';
55

66
import type { ComponentDriverType } from '../component';
77
import { CONTEXT } from '../constants';
8+
import { ZoidComponentInstance } from "../component";
89

910
// eslint-disable-next-line flowtype/require-exact-type
1011
declare class ReactClassType {}
1112

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

1523
type ReactElementType = {|
1624

1725
|};
1826

1927
type ReactType = {|
20-
Component : __ReactComponent,
28+
Component : typeof __ReactComponent,
2129
createClass : ({| render : () => ReactElementType, componentDidMount : () => void, componentDidUpdate : () => void |}) => (typeof ReactClassType),
2230
createElement : (string, ?{ [string] : mixed }, ...children : $ReadOnlyArray<ReactElementType>) => ReactElementType
2331
|};
2432

2533
type ReactDomType = {|
26-
findDOMNode : (typeof ReactClassType) => HTMLElement
34+
findDOMNode : (__ReactComponent) => HTMLElement
2735
|};
2836

2937
type ReactLibraryType = {|
@@ -35,7 +43,7 @@ type ReactLibraryType = {|
3543
/**
3644
* Util to check if component is currently mounted
3745
*/
38-
function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) : boolean {
46+
function isMounted(component : __ReactComponent, ReactDOM : ReactDomType) : boolean {
3947
try {
4048
return Boolean(ReactDOM.findDOMNode(component));
4149
}
@@ -45,19 +53,16 @@ function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) :
4553
}
4654
}
4755

56+
export const react : ComponentDriverType<*, ReactLibraryType, Class<__ReactComponent>> = {
4857

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

53-
// $FlowFixMe
54-
return class extends React.Component {
60+
return class ZoidReactComponent extends React.Component {
5561
render() : ReactElementType {
5662
return React.createElement('div', null);
5763
}
5864

5965
componentDidMount() {
60-
// $FlowFixMe
6166
const el = ReactDOM.findDOMNode(this);
6267
const parent = init(extend({}, this.props));
6368
parent.render(el, CONTEXT.IFRAME)

0 commit comments

Comments
 (0)