#prevent useSubmit() to navigate to another page

1 messages · Page 1 of 1 (latest)

sudden latch
#

Hi, The component is reusable and the loader API that I need to set is under root.tsx, now that the component is reused in every route, why it's always navigated back to the root '/' ?

example working below
`
const submit = useSubmit();

function handleLocale(locale: string) {
return submit({ locale: locale }, { action: '/', method: 'post', replace: true });
}

<ul ariaLabel="translate" icon={<Icon name="translate" />}>
<li disabled>Your language</li>
<li onClick={() => handleLocale('en')}>English</li>
<li onClick={() => handleLocale('es')}>Spanish</li>
</ul>
`

wide coyote
#

Submissions are navigations, and you're giving it an action of /. If you don't want it to navigate you probably want useFecher().submit