React: how to check how many times a user logged in?

I need to show a popup (form for feedback) after a same user visits and logsIn to our site (let´s say) 4-5 times. Has anyone an opinion on how would be the best approach for this? Thanks!

Upvotes: 1

Views: 1669

Answers (2)

Trebolete
Trebolete

Reputation: 125

If you want to track the login count during the same browser session, I would use redux to store into the application global state the successful loggin attempts. Then you can show the modal when the count is greater than the number you decide (4 or 5).

If you want to track the historical login count, you'll need to store this information into the backend database to don't lose information between sessions.

Upvotes: 1

Dani
Dani

Reputation: 584

This npm package can help you display and manage popups easily. Once the user has logged in you can show this popup or alternatively redirect him to another page. You can store a variable isLoggedIn that shows if the user is logged in and show components accordingly

Upvotes: 0

Related Questions