0
I’ve been using React for a short time, and I use the browser’s native Apis a lot, for example to add or remove classes with events. My question is, is this a bad practice? I should try to make these changes using Hooks?
0
I’ve been using React for a short time, and I use the browser’s native Apis a lot, for example to add or remove classes with events. My question is, is this a bad practice? I should try to make these changes using Hooks?
Browser other questions tagged react
You are not signed in. Login or sign up in order to post.
I would say "bad practice," yes. Most of the time, if you are using React, the browser’s native Apis become unnecessary, since React provides other means to achieve the "same result". It doesn’t make much sense to mix.
– Luiz Felipe
Difficult to answer something so broad because of corner cases. For example, it’s not nice to use
document.querySelector
, but you may need this to use the Reactdom.createPortal, which is then a valid use case.– Rafael Tavares