You are viewing a single comment's thread. Return to all comments →
my UI is Updating the count correct but test cases not paaing why.
import React, { useState } from "react";
const FeedbackSystem = () => { const [aspects, setAspects] = useState({"Readability" : {upVote : 0 , downVote : 0}, "Performance" : {upVote : 0 , downVote : 0}, "Security" : {upVote : 0 , downVote : 0}, "Documentation" : {upVote : 0 , downVote : 0}, "Testing" : {upVote : 0 , downVote : 0}, })
const onChangeVoteCount = (aspect , action) => { setAspects((prev) => ({ ...prev , [aspect] : {...prev[aspect], [action] : prev[aspect][action] + 1 } })) }
return ( {Object.keys(aspects).map((key,i) => (
${aspects[key].downVote}
</div> </div>
); };
export default FeedbackSystem;
Seems like cookies are disabled on this browser, please enable them to open this website
Code Review Feedback
You are viewing a single comment's thread. Return to all comments →
my UI is Updating the count correct but test cases not paaing why.
import React, { useState } from "react";
const FeedbackSystem = () => { const [aspects, setAspects] = useState({"Readability" : {upVote : 0 , downVote : 0}, "Performance" : {upVote : 0 , downVote : 0}, "Security" : {upVote : 0 , downVote : 0}, "Documentation" : {upVote : 0 , downVote : 0}, "Testing" : {upVote : 0 , downVote : 0}, })
const onChangeVoteCount = (aspect , action) => { setAspects((prev) => ({ ...prev , [aspect] : {...prev[aspect], [action] : prev[aspect][action] + 1 } })) }
return ( {Object.keys(aspects).map((key,i) => (
{key}
downvote-btn-{i}} onClick={() => onChangeVoteCount(key , "downVote")}> 👎 Downvote upvote-count-${i}}> Upvotes: {aspects[key].upVote} downvote-count-${i}}> Downvotes: {${aspects[key].downVote}
} ))}); };
export default FeedbackSystem;