#submit() fails to find correct routing path

1 messages · Page 1 of 1 (latest)

torn portal
#

Hey guys, I've been trying to follow the dark mode example and also tutorial provided here (https://www.mattstobbs.com/remix-dark-mode/#3-persisting-the-users-choice) to implement into an app based off of the remix indie stack. I've been struggling with an error where I get a 404 response upon calling this line of code which is inside of theme-provider.tsx:

persistThemeRef.current.submit({ theme }, { action: 'action/set-theme', method: 'post' });

where persistThemeRef is a mutable ref object of persistTheme which is set equal to useFetcher().

It seems the error is regarding not being able to find action/set-theme route, which I'm not sure why as I think I'm doing routing correctly. I have a routes folder which contains subdirectories and index.tsx files, with one _index.tsx file at the root level of routes, as well as a utils folder for theme-provider.tsx (image attached).

Am I doing something wrong with my routing here? should I be providing a different path to action/set-theme?

night smelt
#

Unless you're using a custom route convention, there should be no nesting folders in your routes directory

#

routes/action.set-theme.tsx should be the filename there

torn portal
#

Ohhh, I see - I thought that was just the way it had to be done, like even the github code example on dark mode showed it the same way, I'll try doing that real quick

night smelt