react-hook-form, how to set values, which dosent come from input

silly question, when i put postId as input value it works, i tried to make object too but dosent work. those 2 options dosent work, only option that work for me when i put input value postIdQuery, is there better way?
const onSubmit =
(values: CreateParentCommentInput) => {
const payload = {
...values,
postId: postIdQuery
}
mutate(payload);
}
//////////
const postIdQuery = String(router.query.blogId)
const onSubmit =
(values: CreateParentCommentInput) => {
mutate({
id: values.id,
body: values.body,
postId: postIdQuery
});
}
const onSubmit =
(values: CreateParentCommentInput) => {
const payload = {
...values,
postId: postIdQuery
}
mutate(payload);
}
//////////
const postIdQuery = String(router.query.blogId)
const onSubmit =
(values: CreateParentCommentInput) => {
mutate({
id: values.id,
body: values.body,
postId: postIdQuery
});
}
2 Replies
Neto
Neto2y ago
l
l2y ago
thanks ❤️
Want results from more Discord servers?
Add your server