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

Layout component remounts when throwing an error in an action #10005

Open
brookslybrand opened this issue Sep 19, 2024 · 0 comments
Open

Layout component remounts when throwing an error in an action #10005

brookslybrand opened this issue Sep 19, 2024 · 0 comments

Comments

@brookslybrand
Copy link
Contributor

Reproduction

https://stackblitz.com/edit/remix-run-remix-h3kxyf?file=app%2Froot.tsx,app%2Froutes%2F_index.tsx

System Info

System:
    OS: macOS 14.6.1
    CPU: (8) arm64 Apple M1 Pro
    Memory: 285.50 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    npm: 10.8.3 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.10.0 - ~/Library/pnpm/pnpm
    bun: 1.1.0 - ~/.bun/bin/bun
  Browsers:
    Chrome: 128.0.6613.138
    Safari: 17.6
  npmPackages:
    vite: 5.4.0 => 5.4.0 


### Used Package Manager

npm

### Expected Behavior

According to the [Layout docs](Avoids React from re-mounting your app shell elements when switching between the root component/HydrateFallback/ErrorBoundary which can cause a FOUC if React removes and re-adds <link rel="stylesheet"> tags from your <Links> component.)

> Avoids React from re-mounting your app shell elements when switching between the root component/HydrateFallback/ErrorBoundary which can cause a FOUC if React removes and re-adds <link rel="stylesheet"> tags from your <Links> component.

### Actual Behavior

It looks like the `Layout` component in `root.tsx` is remounting if you throw an error from an `action`. If you put an `ErrorBoundary` inside of the child (`routes/_index.tsx`) the remounting goes away and works the way I would expect.

Either:
1. This is a bug
2. This is intended for some reason, and we need to clarify the language in the documentation


https://github.com/user-attachments/assets/86339e99-953b-46f1-ab1c-549920e6f2b2

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

No branches or pull requests

1 participant