Closed jfw2855 closed 2 years ago
What happens when you just console log res.data
when you get/set the transaction?
transactions is just an array of the user's transaction data. We set this to transaction then map through to render coin transaction data.
You're hard-coding a specific item in the transactions array as the setSelected, and it'll always be the first item because you're using [0]
, find a way to get the specific transaction that has been picked
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
I'm trying to fix an issue with the modal only pulling the last item in the transactions array.
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
We don't see an error, but it only edits the last elements transaction data instead of updating the element selected. (clicking the edit button for the first item will render the last element's data and save the data to that last element).
What is your best guess as to the source of the problem?
It has to do with our setSelected not updating the EditTransactionModal at the handleEdit function.
What things have you already tried to solve the problem?
We tried moving this into a function, the component inside the map function and outside, but nothing seems to fix the issue. https://stackoverflow.com/questions/66532393/modal-only-shows-last-element-of-mapped-array-in-react https://stackoverflow.com/questions/57220998/react-bootstrap-modal-only-take-last-item-of-map
Paste a link to your repository here https://github.com/jfw2855/CryptoTracker-Client