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
constyourFn=createServerFn({method: 'POST'}).validator((formData)=>{if(!(formDatainstanceofFormData)){thrownewError('Invalid form data')}constname=formData.get('name')if(!name){thrownewError('Name is required')}returnname}).handler(async({data: name})=>{console.log(name)// 'John'})console.info(yourFn.url)
functionComponent(){return(<formaction={yourFn.url}method={yourFn.method/* <-------- This */}><inputname="name"defaultValue="John"/><buttontype="submit">Click me!</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
-
From docs
instead of hardcoding the method in
form
,it would be great if we can do this.
Just for the sake of DX
Beta Was this translation helpful? Give feedback.
All reactions