Skip to content

Invariant failed when using custom Outlet component from another package #4220

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

Open
tomshane opened this issue May 21, 2025 · 7 comments
Open

Comments

@tomshane
Copy link

Which project does this relate to?

Router

Describe the bug

This happens ONLY in production.

When using Outlet inside a component in a package outside the main project, there is error "Invariant failed".

I have uploaded an example with two projects, one referencing the other.

  • 'my-lib' - contains MyOutlet component
  • 'my-app' referencing my-lib and using MyOutlet component

You can reproduce the error when you run "npm run preview" from the "my-app" project.

Your Example Website or App

.

Steps to Reproduce the Bug or Issue

Run "npm run preview" from the "my-app" project and navigate to the page.

Expected behavior

Application should load properly.

Screenshots or Videos

Image

Platform

  • OS: Windows
  • Browser: Chrome
  • Version: 1.120.5

Additional context

Example with the problem:
router.zip

@MYKEU
Copy link

MYKEU commented May 21, 2025

Experiencing the same as well - also seeing errors if using the below on different packages:

useSearch({ strict: false })

@schiller-manuel
Copy link
Contributor

@tomshane i could not reproduce this issue when running your example locally

@tomshane
Copy link
Author

@schiller-manuel Did you run it in vite preview mode? I've tried it on two different machines, on both it failed.

router.mp4

@schiller-manuel
Copy link
Contributor

must be a npm install issue. it works with pnpm and fails for me with npm
maybe some peer deps resolution?

@tomshane
Copy link
Author

I've tried it with pnpm and it works for me too. Don't know where is the problem, though, it's basically just react and tsr.

@schiller-manuel
Copy link
Contributor

maybe installing multiple / different router version (or any other related deps)?
try checking the lock files and node_modules folder

@tomshane
Copy link
Author

Both packages use v1.120.5. I compared node_modules folders produced by NPM and PNPM and the content is quite different. However, I'm not sure how to setup the package to work with NPM correctly.

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

No branches or pull requests

3 participants