aksal
aksal

Reputation: 559

How to prevent other user access a page when there is any user still access the page in ReactJS?

Scenario:

  1. I have a list of data to edit
  2. When I visit the details data page, the data status is "in review" and means that other user is restricted to edit this data when I still on the page
  3. When I do nothing in the details page, the data status reset to previous state and other user can access it

I have tried to solve this problem with updating the data state when the page is didMount, cache the previous data, and revert it back when the page is unmounting. But, I think it is will affect to the database because everytime a user visit the details page, it will send data to the database.

So, I want to know if there is alternative to solve this problem with a realtime approach in ReactJS.

Upvotes: 0

Views: 54

Answers (1)

Nicola Scionti
Nicola Scionti

Reputation: 536

The frontend is executed in the browser of each user, and the data inside the frontend is duplicated for every user. So you can't solve your problem involving just the frontend. You need to inform the backend that a user is editing the page, and then the backend shoud inform the frontend that the page is in editing state.

Upvotes: 1

Related Questions