Skip to content
Snippets Groups Projects
Commit f4d152b0 authored by Felipe D'Abrantes's avatar Felipe D'Abrantes
Browse files

Wait for question to insert before updating page

parent 388bd0a0
No related branches found
No related tags found
1 merge request!25Add a question management page
...@@ -3,7 +3,7 @@ import { Dispatch, FC, FormEvent, SetStateAction } from 'react'; ...@@ -3,7 +3,7 @@ import { Dispatch, FC, FormEvent, SetStateAction } from 'react';
type NewQuestionFormProps = { type NewQuestionFormProps = {
newQuestion: string; newQuestion: string;
setNewQuestion: Dispatch<SetStateAction<string>>; setNewQuestion: Dispatch<SetStateAction<string>>;
onSubmit: () => void; onSubmit: () => Promise<void>;
}; };
const NewQuestionForm: FC<NewQuestionFormProps> = ({ newQuestion, setNewQuestion, onSubmit }) => { const NewQuestionForm: FC<NewQuestionFormProps> = ({ newQuestion, setNewQuestion, onSubmit }) => {
......
...@@ -24,8 +24,8 @@ const Questions = () => { ...@@ -24,8 +24,8 @@ const Questions = () => {
await fetch(endpoint, options); await fetch(endpoint, options);
}; };
const onQuestionSubmit = (): void => { const onQuestionSubmit = async (): Promise<void> => {
insertNewQuestion(newQuestion); await insertNewQuestion(newQuestion);
setRehydrateQuestions(true); setRehydrateQuestions(true);
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment