Favorites Page (/favorites)
I personally like the idea of being able to “star” certain stocks and having a favorites list to which you can return to essentially check your watchlist. Therefore I’m going to implement that next.
First of all I need to save and load this favorites list. I don’t plan on adding an account management system right now especially because none of the features would benefit from it aside from this one. So I’ll take a simpler approach and save the list to local storage. This way the user’s favorites will get stored locally in his browser. This saving is done by the star component in the Stock Page.
I created a separate route /favorites
. This route then displays the Favorites
component.
Favorites simply loads the favorites
array from local storage and renders them as a list. For every element in the array it then renders a row container with the logo, ticker, title and sentiment score of the company. Said information is fetched from the /retrieve-analysis
endpoint with the ticker from the array as the parameter. When an element is clicked it simply links to it’s respective stock page URL. This is done through the Link
component from react-router-dom
. This way the content is just re-rendered and there’s a smooth transition.