Skip to content

Commit

Permalink
fix(react): fix all 'react' driver flow / lint errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmilar committed Feb 5, 2021
1 parent 3d698b8 commit cf61b10
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/drivers/react.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@ import { extend, noop } from 'belter/src';

import type { ComponentDriverType } from '../component';
import { CONTEXT } from '../constants';
import { ZoidComponentInstance } from "../component";

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

// eslint-disable-next-line flowtype/require-exact-type
declare class __ReactComponent {}
declare class __ReactComponent {
state : {| parent? : ZoidComponentInstance<*> |},
props : mixed,
setState : (newStateOrFn : mixed) => void
}

// eslint-disable-next-line flowtype/require-exact-type
type Class<T> = { new(): T };

type ReactElementType = {|

|};

type ReactType = {|
Component : __ReactComponent,
Component : typeof __ReactComponent,
createClass : ({| render : () => ReactElementType, componentDidMount : () => void, componentDidUpdate : () => void |}) => (typeof ReactClassType),
createElement : (string, ?{ [string] : mixed }, ...children : $ReadOnlyArray<ReactElementType>) => ReactElementType
|};

type ReactDomType = {|
findDOMNode : (typeof ReactClassType) => HTMLElement
findDOMNode : (__ReactComponent) => HTMLElement
|};

type ReactLibraryType = {|
Expand All @@ -35,7 +43,7 @@ type ReactLibraryType = {|
/**
* Util to check if component is currently mounted
*/
function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) : boolean {
function isMounted(component : __ReactComponent, ReactDOM : ReactDomType) : boolean {
try {
return Boolean(ReactDOM.findDOMNode(component));
}
Expand All @@ -45,19 +53,16 @@ function isMounted(component : typeof ReactClassType, ReactDOM : ReactDomType) :
}
}

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

export const react : ComponentDriverType<*, ReactLibraryType, typeof ReactClassType> = {

register: (tag, propsDef, init, { React, ReactDOM }) => {
register: (tag, propsDef, init, { React, ReactDOM }) : Class<__ReactComponent> => {

// $FlowFixMe
return class extends React.Component {
return class ZoidReactComponent extends React.Component {
render() : ReactElementType {
return React.createElement('div', null);
}

componentDidMount() {
// $FlowFixMe
const el = ReactDOM.findDOMNode(this);
const parent = init(extend({}, this.props));
parent.render(el, CONTEXT.IFRAME)
Expand Down

0 comments on commit cf61b10

Please sign in to comment.