Skip to content

Commit

Permalink
chore: fix onChange typing
Browse files Browse the repository at this point in the history
  • Loading branch information
niels-bosman committed Nov 4, 2023
1 parent bd68615 commit 3877e50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@magicul/react-chat-stream",
"description": "A React hook that lets you easily integrate your custom ChatGPT-like chat in React.",
"version": "0.2.0",
"version": "0.2.1",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"homepage": "https://github.com/XD2Sketch/react-chat-stream#readme",
Expand Down
14 changes: 2 additions & 12 deletions src/hooks/useChatStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,6 @@ type ChatMessage = {
id: string;
}

type UseChatStreamResult = {
messages: ChatMessage[];
setMessages: Dispatch<SetStateAction<ChatMessage[]>>
input: string;
setInput: Dispatch<SetStateAction<string>>;
handleInputChange: (event: ChangeEvent<HTMLInputElement>) => void;
handleSubmit: (event?: FormEvent<HTMLFormElement>, newMessage?: string) => void;
isLoading: boolean;
}

export type UseChatStreamOptions = {
url: string;
method: HttpMethod;
Expand All @@ -40,12 +30,12 @@ type UseChatStreamInput = {
method: UseChatStreamInputMethod,
};

const useChatStream = (input: UseChatStreamInput): UseChatStreamResult => {
const useChatStream = (input: UseChatStreamInput) => {
const [messages, setMessages] = useState<ChatMessage[]>([]);
const [message, setMessage] = useState('');
const [isLoading, setIsLoading] = useState(false);

const handleInputChange = (e: ChangeEvent<HTMLInputElement>) => {
const handleInputChange = (e: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLTextAreaElement>) => {
setMessage(e.target.value);
};

Expand Down

0 comments on commit 3877e50

Please # to comment.