diff --git a/README.md b/README.md index ec08486..bac1410 100644 --- a/README.md +++ b/README.md @@ -31,12 +31,36 @@ 1. How long did you spend on the coding? + 2.5 hours + 2. What would you add to your solution if you had more time? + - Implement navigation to allow users to browse all the books in the JSON file, with controls to navigate + between pages. + - Add an option for the user to select how many books to dislay per page and display full JSON file. + - Add a search feature to filter books by author or title. + - Make the "READ MORE" button functional by displaying additional details from the JSON file, such as language, country, and year of publication. + 3. Share a code snippet that you are proud of and explain what it does + ```js +// Load initial state from localStorage or set to an empty array +const [favourites, setFavourites] = useState(() => { + const stored = localStorage.getItem("favourites"); + return stored ? JSON.parse(stored) : []; +}); + +// Sync favourites with localStorage whenever it changes +useEffect(() => { + localStorage.setItem("favourites", JSON.stringify(favourites)); +}, [favourites]); +``` + After implementing the core functionality, I noticed that the favourites list was reset on page reload. To address this, I used localStorage to persist the favourites state and ensure data remains available across sessions. + + 4. How would you track down a performance issue in production? Have you ever had to do this? + I have not but I'm eager to learn more about it! --- # Comments diff --git a/app/index.html b/app/index.html index 79c4701..94415e2 100644 --- a/app/index.html +++ b/app/index.html @@ -3,11 +3,26 @@
+ +