Skip to content

Instantly share code, notes, and snippets.

@ljmotta
Last active October 14, 2020 13:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljmotta/a3b8259d1b23a48bc17e9318fdb7b0e2 to your computer and use it in GitHub Desktop.
Save ljmotta/a3b8259d1b23a48bc17e9318fdb7b0e2 to your computer and use it in GitHub Desktop.
TodoListEnvelopeView Ref Forwarding Component
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