Set up a form (in this case it’s Material UI textField)
1
2
3
4
5
6
7
8
9
10
11
12
<formonSubmit={handleSubmit}><TextFieldonChange={(e)=>onHandleChange(e,"key")}label="field"//shown above text box
placeholder="Enter field"//shown in text box
type="key"//idek
fullWidthrequired/>;</form>//remember to have button with type submit !
Each time an input form gets changed, call onHandleChange()
1
2
3
4
5
6
7
8
9
10
11
constonHandleChange=(e,field)=>{//e = event
switch(field){//only change the changed value
case"key1":setFormParams({...formParams,key1:e.target.value});//keeps old value
break;case"key2":setFormParams({...formParams,key2:e.target.value});break;}};
Once the form is submitted,
1
2
3
4
5
6
7
8
9
10
11
12
consthandleSubmit=async(e)=>{e.preventDefault();//prevent page reload
constrequest=awaitAPIFirebase.signUp(formParams.key1,formParams.key2);//api call to store data into firebase
if(!request){//if no response
console.log("Signup Failed!");}else{//request successful
console.log("Signup Successful!");}};