Home  >  Q&A  >  body text

What's the way to force an action to be triggered using useSubmit without any checks?

<p><strong>react-router-dom v6</strong></p><p>When I submit the operation using the get method</p> <pre class="brush:php;toolbar:false;">useEffect(() => { if (!standardSelected) return; clearTimeout(sectionListTimeOutId); const clearTimeoutId = setTimeout(() => { console.log('>>> use submit called'); submit({ standard_id: standardSelected }, { method: 'get' }); }, 1000); setSectionListTimeOutId(clearTimeoutId); }, [standardSelected]);</pre> <p>My action function is not triggered because the action will only be triggered by methods other than the "GET" method. </p><p><strong>How can I force useSubmit to trigger an action without checking anything. </strong></p>
P粉301523298P粉301523298455 days ago507

reply all(1)I'll reply

  • P粉852114752

    P粉8521147522023-08-15 09:42:15

    If you want to force an action to be triggered, you can use the "post" method instead of "get"

    useEffect(() => {
        if (!standardSelected) return;
        clearTimeout(sectionListTimeOutId);
        const clearTimeoutId = setTimeout(() => {
          console.log('>>> use submit called');
          submit({ standard_id: standardSelected }, { method: 'post' });
        }, 1000);
        setSectionListTimeOutId(clearTimeoutId);
      }, [standardSelected]);
    

    reply
    0
  • Cancelreply