Skip to content

Commit

Permalink
Update type.
Browse files Browse the repository at this point in the history
  • Loading branch information
dicky authored and dicky committed May 24, 2020
1 parent 7c78f54 commit 3adefd3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
11 changes: 1 addition & 10 deletions DevApp/src/dotnetify/_typings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,4 @@ export interface IScopeProps {

export class Scope extends React.Component<IScopeProps> {}

export const useConnect = function<T>(
vmId: string,
component?:
| {
state: T;
props: any;
}
| any,
options?: IConnectOptions
): any {};
export declare const useConnect: <T>(vmId: string, component?: any, options?: IConnectOptions) => { vm: IDotnetifyVM; state: T };
12 changes: 10 additions & 2 deletions DevApp/src/dotnetify/react/useConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import * as $ from "../libs/jquery-shim";
import dotnetify from "./dotnetify-react";
import { IDotnetifyVM, IConnectOptions } from "../_typings";

dotnetify.react.useConnect = function<T>(iVMId: string, iComponent?: { state: T; props: any } | any, iOptions?: IConnectOptions) {
dotnetify.react.useConnect = function<T>(
iVMId: string,
iComponent?: { state: T; props: any } | any,
iOptions?: IConnectOptions
): { vm: IDotnetifyVM; state: T } {
if (useState == null || useEffect == null) throw "Error: using React hooks requires at least v16.8.";

let { state, props } = iComponent;
Expand Down Expand Up @@ -50,6 +54,10 @@ dotnetify.react.useConnect = function<T>(iVMId: string, iComponent?: { state: T;
return { vm: vm.current, state: _state };
};

export default function<T>(iVMId: string, iComponent?: { state: T; props: any } | any, iOptions?: IConnectOptions) {
export default function<T>(
iVMId: string,
iComponent?: { state: T; props: any } | any,
iOptions?: IConnectOptions
): { vm: IDotnetifyVM; state: T } {
return dotnetify.react.useConnect(iVMId, iComponent, iOptions);
}

0 comments on commit 3adefd3

Please sign in to comment.