You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We're using Felte in a React component that includes some conditional rendering. We've noticed that in this setup, Felte doesn't seem to initialize correctly, which I suspect is due to the form reference not being set properly.
This will trigger native submit on the form element, felte submit handler won't work in this case.
Is there a way to ensure proper initialization in such cases? Specifically, can we pass dependencies to useForm to address this issue?
exportfunctionFelteForm(){const[fakeDataLoaded,setFakeDataLoaded]=useState(false);const{ form }=useForm({onSubmit: (values)=>{alert("felte submit triggered");},});useEffect(()=>{setTimeout(()=>{setFakeDataLoaded(true);},1000);},[]);// this part is the issueif(!fakeDataLoaded){return<div>loading...</div>;}return(<formref={form}method="POST"action="/api/fake-endpoint"><inputtype="text"name="email"/><inputtype="password"name="password"/><buttontype="submit">Sign In</button></form>);}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi everyone,
We're using Felte in a React component that includes some conditional rendering. We've noticed that in this setup, Felte doesn't seem to initialize correctly, which I suspect is due to the form reference not being set properly.
This will trigger native submit on the form element,
felte
submit handler won't work in this case.Is there a way to ensure proper initialization in such cases? Specifically, can we pass dependencies to
useForm
to address this issue?Here is the test repo:
https://github.com/rodilo/felte-test/blob/master/src/components/FelteForm.js
Thank you for your help!
Beta Was this translation helpful? Give feedback.
All reactions