#Is it ok to use document.getElementById() ?
74 messages · Page 1 of 1 (latest)
Just use the refs idk why it would be shorter without them
Because the refs need to be instanciated on the top of the file and the getElement can happen conditionally
If it works it works
?
Do what you have to do
Just use the FormData web api
The FormData interface provides a way to easily construct a set of key/value pairs representing form fields and their values, which can then be easily sent using the fetch() or XMLHttpRequest.send() method. It uses the same format a form would use if the encoding type were set to "multipart/form-data".
@fair urchin An advice that helped me alot is to not be afraid of longer codes / larger functions.
I hate this api, Imma stick to refs😁
I am not, I just feel like it is a waste of memory to keep those inputs hooked to a state variable
Also depends what you need for the form
I need to track the values only on submit
Does it need to check if the input is correct at any time or only submit
Ahh alright uncontrolled it is
Seems you got it under control then
You can add a listener (attribute) that passes the form as an object to your function
something like onSubmit((e) => myfunc(e))
Then extract the values from e
I know most of the posibilities. the reason I am asking is because of some comments I got from advanced react devs who bashed me for using native apis in react
Yeah, I know
Depends which ones though as some don’t work too well if done wrong
But the docs and some seniors have told me that it is a really bad practice
Meh
Depends, some more depends finally some depends.
It’s a very black and white picture your “seniors” are throwing at you lol
Maybe they aren’t as senior as you think
I know
Completely correct
Opinionates asf
But I have no other choice than to follow their instructions
A lot of people are held back by sticking to the easy route, taking the easy way, believing they are always right, instead of going out and experimenting
I love actually seeing both sides of the argument but my company situation is opinionated
Not in the best way of course
I am a student as well but with a job
I am not the one paying so I can't force my practices onto them
School is free here 🤘
Where ?
Oo finland ?