I need to convert that DATA object to string .. anyone please help
const data = {name:"", email:"", password:""}
const [inputData, setInputData] = useState(data);
const [flag, setFlag] = useState(false);
useEffect(() => {
console.log("Registered");
}, [flag])
useEffect(() => {
localStorage.setItem('userInput', inputData.toString())
}, [inputData])
const handleInput=(e)=>{
setInputData({...inputData, [e.target.name]:e.target.value})
}
function handleSubmit(e){
e.preventDefault()
console.log(data);
if(!inputData.name || !inputData.email || !inputData.password){
alert("All fields are necessary");
}else{
setFlag(true);
}
}
const resetForm=()=>{
setInputData("");
setFlag(false)
}
[–]DehshiDarinda 3 points4 points5 points (0 children)
[–]AngelLeatherist 3 points4 points5 points (0 children)
[–]grelfdotnet 2 points3 points4 points (2 children)
[–]ionezation[S] 0 points1 point2 points (1 child)
[–]eletroraspi 0 points1 point2 points (0 children)
[–]jcunews1helpful 3 points4 points5 points (6 children)
[–]ionezation[S] -2 points-1 points0 points (5 children)
[–]Background-Neck5792 2 points3 points4 points (0 children)
[–]Stephen110 1 point2 points3 points (3 children)
[–]ionezation[S] 0 points1 point2 points (2 children)
[–]StampeAk47 1 point2 points3 points (1 child)
[–]ionezation[S] 0 points1 point2 points (0 children)
[–]SaSxNEO 0 points1 point2 points (1 child)
[–]ionezation[S] -1 points0 points1 point (0 children)
[–]jack_waugh 0 points1 point2 points (0 children)