Is it mandatory to set a state for all events?

Asked

Viewed 31 times

0

Well, my doubt may be a little unethical, but either way, it’s something I’m curious about. Am I required to set a state for all events on the screen? Let me try to explain... I have a list of users that I return from an API, for each user I show the id, name and type of user(admin, etc.). Only I have two features in this list to disable the user and edit it, when I click to edit I call a function that takes the id and the value "flex", in this function I get q div who owns the id using the javascript api of manipulating the DOM and give a style.display = value(which is "flex" or "None"). Is that good practice? Or would I have to set a state to give the toggle and if yes, how could I do that.

  • 1

    wrong to do so: style.display = value(que é "flex" ou "none")

  • And how could I do that?

  • missing you post a minimum example of your code

  • I did some research, and I saw that I had to create a separate component for what will be covered. I did and it worked, I can make the toggle in a cleaner way. I ended up separating in 3 components s what was only 1

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.