I would do it this way:
const [userId, setUserId] = useState(""); const updatedUser = list.find((user) => user._id === userId); const { email, username, password } = updateUser;
const updateUserId = (id) => setUpdateId(id) is redundant as well as you can just use setUserId directly
Yes but I needed 3 different states of email , username and password because i have three inputs which change these states and update the value using those input fields
Personally I would group these as an object. They're all related, so why have seperate individual states, updaters, etc. for each?
If i have to send this data (I'd,email,username and password) to the backend for MongoDb query then please write the short logic for it
It was a nice "reminder" to use proper functions.
Okay i would try to re-code this thing As i don't want to mess up the backend part which is already set and i am new to this 😂😂
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I would do it this way:
const updateUserId = (id) => setUpdateId(id) is redundant as well as you can just use setUserId directly
Yes but I needed 3 different states of email , username and password because i have three inputs which change these states and update the value using those input fields
Personally I would group these as an object. They're all related, so why have seperate individual states, updaters, etc. for each?
If i have to send this data (I'd,email,username and password) to the backend for MongoDb query then please write the short logic for it
It was a nice "reminder" to use proper functions.
Okay i would try to re-code this thing
As i don't want to mess up the backend part which is already set and i am new to this 😂😂