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

useContext does not work when ContextProvider is declared in route after HMR #10113

Open
pstachula-dev opened this issue Oct 15, 2024 · 0 comments
Labels

Comments

@pstachula-dev
Copy link

Reproduction

  1. Go to the route /test.
  2. Click on click
  3. Check the developer console - it should work correctly - both inside + outside change state
  4. Change the code, add a space or something.... now after HMR inside is fine, but outside has the wrong state

When I move the BugContext from the route to a separate file, it starts working correctly.

https://stackblitz.com/edit/remix-run-remix-v7duwb?file=app%2Froutes%2Ftest.tsx

System Info

System:
    OS: Linux 6.11 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 24.47 GB / 31.27 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Binaries:
    Node: 20.17.0 - ~/.nvm/versions/node/v20.17.0/bin/node
    Yarn: 1.22.22 - /usr/bin/yarn
    npm: 10.8.2 - ~/.nvm/versions/node/v20.17.0/bin/npm
    pnpm: 9.9.0 - ~/.nvm/versions/node/v20.17.0/bin/pnpm
    bun: 1.1.27 - ~/.bun/bin/bun
  Browsers:
    Brave Browser: 129.1.70.123
    Chromium: 129.0.6668.89
  npmPackages:
    @remix-run/dev: ^2.13.1 => 2.13.1
    @remix-run/node: ^2.13.1 => 2.13.1
    @remix-run/react: ^2.13.1 => 2.13.1
    @remix-run/serve: ^2.13.1 => 2.13.1
    vite: ^5.1.0 => 5.4.3

Used Package Manager

npm

Expected Behavior

Context should works in children component

Actual Behavior

Context work only for children declareated inside 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

2 participants