Skip to content

Commit

Permalink
Fix bug with possible null optimistic mutator
Browse files Browse the repository at this point in the history
  • Loading branch information
bombies committed Oct 29, 2023
1 parent 373be77 commit 422f577
Showing 1 changed file with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@ const AddTagForm: FC<Props> = ({onSuccess}) => {
const onSubmit: SubmitHandler<FormProps> = async (data) => {
if (!session?.user)
return;

await toast.promise(tags.optimisticData
.addOptimisticData(() => handleCreation(data), {
id: '',
...data,
createdAt: new Date(),
updatedAt: new Date(),
userId: session.user.id
}),
{
loading: "Adding new tag...",
success: "Successfully added that tag!",
error: "Could not add that tag!"
}
)
if (tags.optimisticData.addOptimisticData)
await toast.promise(tags.optimisticData
.addOptimisticData(() => handleCreation(data), {
id: '',
...data,
createdAt: new Date(),
updatedAt: new Date(),
userId: session.user.id
}),
{
loading: "Adding new tag...",
success: "Successfully added that tag!",
error: "Could not add that tag!"
}
)

}

Expand Down

0 comments on commit 422f577

Please sign in to comment.