Sort button set up for the challenge on this app.
Instructions were to do the following:
"Add a “sort direction” button to the top of ProductList, above all the products. It
should enable the user to toggle sorting products by ascending or descending."
The feature does work, however when the button is clicked the lower level components don't refresh when you hit the sort button. They only change if you update some data, like changing a vote number.
Sort button set up for the challenge on this app. Instructions were to do the following: "Add a “sort direction” button to the top of ProductList, above all the products. It should enable the user to toggle sorting products by ascending or descending."
All the relevant code is in the app.js file. I added a state to the top level component that toggles based on the button being pressed here: https://github.com/Xerxes25x/VotingApp/blob/master/app.js#L4
When the button is clicked it executes this code: https://github.com/Xerxes25x/VotingApp/blob/master/app.js#L12
added an if/else statement to the sorting procedure based on the new state here: https://github.com/Xerxes25x/VotingApp/blob/master/app.js#L23-L31
The button itself is here: https://github.com/Xerxes25x/VotingApp/blob/master/app.js#L77
The feature does work, however when the button is clicked the lower level components don't refresh when you hit the sort button. They only change if you update some data, like changing a vote number.