Rank 3: Container
Just tell me how to get the id of only one document
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 3: Container
Just tell me how to get the id of only one document
Rank 3: Container
The thing is
Rank 3: Container
if delete document is working properly
Rank 3: Container
Why edit won't work
Rank 3: Container
Hey @safwan Can you a take a look here?
sure let me check
@Susmita could you send you updated code? Also please try to enable JS formatting by typing js after the first 3 backticks
Rank 3: Container
I don't have nitro to do that. It exceeds text limit and can't be formatted
okay no worries can you just the send a file or something?
Rank 3: Container
code is uploaded on github
Rank 3: Container
sharing the links here
This is the problem
If you're using conditional rendering, then, you'll always get the last item as this what that item is
pointingto.
To overcome it, you can try different approaches.
useRef to create a new pointer for the data.Rank 3: Container
Here's the link:- https://github.com/Susmita-Dey/ProManager/blob/main/components/Todos.jsx
@Susmita I just looked through your code. One thing I want to ask is if this issue happens even after you close the modal, and reopen it?
For example:
You said that when you click the last item, it shows the value of the first item right? What happens when you close that modal and try to edit the last item again?
Another thing is to try @Binyamin's suggestion.
Also, why display the value in the placeholder, when you can use the value attribute in the input?
You can store the value in a state, and use that state in the value attribute. Add an onChange attribute to the input that calls the setState function to update the value seamlessly
Rank 3: Container
Yes
Rank 3: Container
When I click on the first/second item, the last item comes up. After closing the modal and reopening it or reloading the page and then reopening the modal, same thing happens
Rank 3: Container
If I click on the last item, then also the last item comes up which is okay that particular one
Rank 3: Container
And every time I hit update button by clicking on any of the edits, the last items gets updated
Rank 3: Container
Thanks @Binyamin and @safwan
Rank 3: Container
Solved the issue by using a state variable to point the selected item
Rank 3: Container
[SOLVED] Last document getting updated