Friday, October 6, 2023

167: Debugging Context

 I encountered a strange bug in my app. After clicking a specific crypto, the app navigates to the coin's page properly and renders the name, icon, and price chart. However, the current price and marketcap would not show. Changing the currency in the navbar will succesfully update everything, so this bug only existed in the initial load. The fact that the coin name loaded successful means that the useParams hook was successful pulling info from the URL, so that wasn't the issue. The coin would also show its market dominance rank, so the API seemed to be working fine. More puzzling was the fact that the dollar symbol showed ($) on the price area, so it seemed like the currency object in context was being passed properly as well. I used the react dev tools to navigate to my price chart component and investigate the object it received from context and found the issue: the initial value for the context was set to USD in all caps. The capitalized string was not valid in the object returned by the API, so those lines never rendered. The bug was fixed and the price renders properly now on the initial pageload. 

No comments:

Post a Comment

190: Sablier

 The CodeHawks platform has an upcoming audit on the Sablier protocol, so I decided to read through the docs and familiarize myself with the...