Skip to content

How to keep the state of the id/ids that need to be deleted? #567

Answered by kachar
dpmarkov asked this question in Q&A
Discussion options

You must be logged in to vote

I'm gonna share some ideas on how I've resolved similar scenarios before

The general idea is to keep the state encapsulated in a hook and use that hook whenever we need confirmation for deletion.

Using a modal store would lead us in direction of breaking the open/closed SOLID principle as everyone will be able to open or close our modal even if we do not expect that.
Using a single instance modal store would lead to having a collection of records/ids that belong to different entities at the same time.

My suggestion for this functionality:

  • split record details functionality from confirmation of deletion, at the moment both of them are in the same modal store
  • create dedicated hook useConfirm

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by kachar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment