tom-sherman / rescript-remix

MIT License
30 stars 5 forks source link

`useFetcher` bindings #2

Open tom-sherman opened 2 years ago

tom-sherman commented 2 years ago

Ideally we should use a variant for the fetcher type, this may require wrapping the remix useFetcher and adding some small conversion functions.

youngkidwarrior commented 2 years ago

Im trying to make a resource route from an unconventional route filename.

when I call Fetcher.load() I am getting an error where the data is looking in the unconventional route

my folder structure looks like this

app/
├── res-routes/
│   └── Root_FetchGuilds.js
│   └── Root_Index.js
├── routes/
│   └── index.js
│   └── fetchGuilds.js
└── root.res

routes/fetchGuilds.js imports from res-routes/Root_FetchGuilds

import { loader } from '~/res-routes/Root_FetchGuilds.js'

export { loader }

I am getting this error:

Error: Route "res-routes/Root_FetchGuilds" does not match URL "/fetchGuilds"

and the URL from useFetcher looks like this

/fetchGuilds?_data=res-routes/Root_FetchGuilds

when it should be /fetchGuilds?_data=routes/fetchGuilds