Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: exception on no default in render function #12262

Open
stalexxx opened this issue Nov 12, 2024 · 2 comments
Open

[Bug]: exception on no default in render function #12262

stalexxx opened this issue Nov 12, 2024 · 2 comments
Labels

Comments

@stalexxx
Copy link

stalexxx commented Nov 12, 2024

What version of React Router are you using?

7.0.0.pre.5

Steps to Reproduce

having this code

export async function loader({ params, request }: Route.LoaderArgs) {}
export function TeachLayout() {}

actual problem goes away when adding default

export default function TeachLayout() {}

Expected Behavior

some usefull debug message

Actual Behavior

throwing

Error: Expected a Response to be returned from resource route handler
    at invariant3 (/Users/alex/prj/sotochka/sotka-remix/node_modules/react-router/dist/index.js:8684:11)
    at handleResourceRequest (/Users/alex/prj/sotochka/sotka-remix/node_modules/react-router/dist/index.js:9419:5)
    at requestHandler (/Users/alex/prj/sotochka/sotka-remix/node_modules/react-router/dist/index.js:9205:18)
    at nodeHandler (/Users/alex/prj/sotochka/sotka-remix/node_modules/@react-router/dev/dist/vite.js:1688:30)
    at /Users/alex/prj/sotochka/sotka-remix/node_modules/@react-router/dev/dist/vite.js:1694:17
@stalexxx stalexxx added the bug label Nov 12, 2024
@stalexxx stalexxx changed the title [Bug]: bug [Bug]: exception on no return from loader Nov 12, 2024
@stalexxx stalexxx changed the title [Bug]: exception on no return from loader [Bug]: exception on no default in render function Nov 12, 2024
@bmatzner
Copy link

I ran into this as well. In my case, a resource route with a loader only did not return a valid Response. So the error message was helpful. The message that this is a bug in React Router, however, was not – after all it was an issue in my code, not in React Router.

@discoverlance-com
Copy link

I ran into this same issue and as suggested by @stalexxx, I added the default export and that resolved the issue. I only had an action defined in my resource route.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants