chomosuke / IT-PROJECT-PorkBellyPro

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

calling commit immediately after update does nothing

chomosuke opened this issue · comments

i think it's because of the fact that there's no time for setDetail to take place yet.

I have found a way of getting around this problem, thought it's not very pretty.

Something that might make my life easier is a function to check if there's changes to commit or not.

Under what situation do you need to call commit immediately after update? It does not work as expected because calling update causes your component to re-render, after which commit will correspond to. The user flow is "change field (update) -> press confirm (commit)". Two buttons cannot be clicked simultaneously, the browser UI is single-threaded.

it's about me wanting to enforce an existence of note field. I realized that I do not actually need to commit as i can just ensure the note field always exist locally and well get sent over to remote whenever user click save

If we want to make any assumptions it should be verified server-side. So if you want the note field to always exist, we should define it on the REST API, the Mongoose models, the TypeScript interfaces etc., and update the relevant route handlers.

Alternatively, we just don't include a dedicated note field, let the user add one when they want one. You can make any field text box expand on the UI so that any field can be whatever size needed to fit any amount of content.

guess i don't have to worry about this now, doesn't get into anyone's way or anything