I’m busy with the Ravenous Part 3 exercise and everything ‘seems’ to be working. However, I got stuck when I noticed that my CSS for the filter links wasn’t updating (orange) despite having combed through the forums and questions and the video walkthrough I noticed that the version on the video (and in some of the forum is different (maybe older).
The main difference is that I have to move the sortByOptions object into the SearchBar class and update it using this
I’ve updated the renderSortByOptions to reference these objects with this but when I run the ‘active’ status is not being registered and I also notice that the initial state is not there either.
I understand what you’re saying and it’s what I have concluded myself. but I have no idea how to fix it, and this is also the direction the project instructed me to follow. That being said I could have totally missed a detail but I’m pretty sure I haven’t.
I used Object.entries() for this task. It gives you both the key and the value as an array.
You can still use Object.keys(), but then you have to reference the sortByOptions object to get the related value to your mapped item.
Edit: You do not need to pass the index in case you stick to Object.keys as I wrote earlier since you can reference the property with the key you map: