Retrieve the Router 6 useFetcher method in the form
P粉993712159
P粉993712159 2023-09-06 23:16:42
0
1
409

I have no choice but to call the getter's submit method in the handler. It's accessing the correct action method in the router, but I can't pass that method to the action, which ismethod='POSTdefined in the form. How do I access thefetch.Formmethod inside the handler?

const fetcher = useFetcher() const handlerLogin = useCallback(async () => { console.log(fetcher.formMethod) //-> outputting undefined fetcher.submit({ value: 'social' }, { method: fetcher.formMethod }) },[]) return (   ..............

P粉993712159
P粉993712159

reply all (1)
P粉739942405

Try this solution, passing the method to thehandlerLoginfunction:

const fetcher = useFetcher(); const handlerLogin = useCallback(async (formMethod) => { fetcher.submit({ value: 'social' }, { method: formMethod }); }, []); return (   {/* other parts ... */}    );
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!