You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a usecase where I need the rating for multiple trips that a customer has taken. I am trying to use this in a loop.
When the page is loaded -> useEffect is called and feedbackdetails are loaded for multiple rides. I loop feedbackdetails to render the stars for each ride.
When user submits 3 star for one and clicks on 'Submit Feedback' button, the feedback is submitted correctly but the second ride automatically gets the (same) 3 star rating.
The way I am storing the rating in state is like {index: rating}, but I am resetting it after each loadFeedbackDetails. loadFeedbackDetails will return only the rides that aren't submitted for feedback.
Can someone explain why is this the case?
I am resetting -- setRating({}); when the axios.get happens and I am setting initialValue to initialValue={rating[index] || 0}
I have a usecase where I need the rating for multiple trips that a customer has taken. I am trying to use this in a loop.
When the page is loaded -> useEffect is called and feedbackdetails are loaded for multiple rides. I loop feedbackdetails to render the stars for each ride.
When user submits 3 star for one and clicks on 'Submit Feedback' button, the feedback is submitted correctly but the second ride automatically gets the (same) 3 star rating.
The way I am storing the rating in state is like {index: rating}, but I am resetting it after each loadFeedbackDetails. loadFeedbackDetails will return only the rides that aren't submitted for feedback.
Can someone explain why is this the case?
I am resetting -- setRating({}); when the axios.get happens and I am setting initialValue to initialValue={rating[index] || 0}
Have been stuck on this issue since 2 days.
const [rating, setRating] = useState({});
const handleRating = (rate: number, index: number) => {
let tempRating = rating;
tempRating[index] = rate;
console.log(tempRating);
setRating(tempRating)
}
function submitFeedBack(item: any, index: number) {
axios.post(process.env.REACT_APP_API + '/feedback?' + 'rating=' + rating[index])
.then((axiosResponse1: AxiosResponse) => {
setRating({});
console.log(axiosResponse1.data);
loadFeedbackDetails();
})
.catch((reason: AxiosError) => {
// TBD
})
}
{feedbackDetails.map((item, index) => (
{
The text was updated successfully, but these errors were encountered: