Real-Dev-Squad / website-status

Shows a roadmap of the ongoing projects being done
https://status.realdevsquad.com/
MIT License
21 stars 145 forks source link

fixed mine route issue #386

Closed kshitij430 closed 1 year ago

kshitij430 commented 1 year ago

This PR fixes issue https://github.com/Real-Dev-Squad/website-status/issues/375

There were two issues . 1) The Mine component was re evaluating in a loop as the useEffect hook had "response" as dependency. 2) The if condition to check if there is a response with length had a not condition which did the opposite. Ex - for 0 results found !0 would evaluate to 1 and !1 would evaluate to a falsy value due to which the setTasks state updating function was not getting executed.

Fixes I have done - 1) Removed response as a dependency as we only want to call the API once when the component is mounted. 2) Removed the condition to check response results as these checks are already done in the JSX return. Ex-> display no results found if length is 0 and otherwise.

vercel[bot] commented 1 year ago

@kshitij430 is attempting to deploy a commit to the RDS-Team Team on Vercel.

A member of the Team first needs to authorize it.

Maheima commented 1 year ago

Please add description to the PR related to why it was happening and how it was fixed

kshitij430 commented 1 year ago

Please add description to the PR related to why it was happening and how it was fixed

Already Done. Can you please review it?

harshith-venkatesh commented 1 year ago

Could you add video to showcase the issue being resolved in different scenarios please @kshitij430

kshitij430 commented 1 year ago

I have added a video considering where no results are found and where 1 or more are found. Now since I did not have any tasks assigned to me I replicated the behavior by duplicating the response as you can see in the video.

https://user-images.githubusercontent.com/59320687/214873419-0a4c5f50-5740-4a38-bd45-fd88942a37d0.mp4

harshith-venkatesh commented 1 year ago

From contract , response can't be null or undefined or some error? If we have proper error handling ,we are good with merging

kshitij430 commented 1 year ago

From contract , response can't be null or undefined or some error? If we have proper error handling ,we are good with merging

I doubt the API will give a null or undefined but In cases if the response might be null or undefined. It is better to check if there is a required response present and then update the state for tasks. In a scenario if there is an error the jsx return will handle it.