Last active
October 14, 2020 13:52
-
-
Save ljmotta/a3b8259d1b23a48bc17e9318fdb7b0e2 to your computer and use it in GitHub Desktop.
TodoListEnvelopeView Ref Forwarding Component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { MessageBusClientApi } from "@kogito-tooling/envelope-bus/dist/api"; | |
import { useState } from "react"; | |
import { Item, TodoListChannelApi } from "../api"; | |
export interface TodoListEnvelopeViewApi { | |
setUser(user: string): void; | |
addItem(item: string): void; | |
getItems(): Item[]; | |
markAllAsCompleted(): void; | |
} | |
interface Props { | |
channelApi: MessageBusClientApi<TodoListChannelApi>; | |
} | |
export const TodoListEnvelopeView = React.forwardRef<TodoListEnvelopeViewApi, Props>((props, forwardedRef) => { | |
const [user, setUser] = useState<string | undefined>(); | |
const [items, setItems] = useState<Item[]>([]); | |
// ... | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment