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

Importing from another route shouldn't duplicate code #1143

Open
sergiodxa opened this issue Dec 19, 2021 · 2 comments
Open

Importing from another route shouldn't duplicate code #1143

sergiodxa opened this issue Dec 19, 2021 · 2 comments
Labels
enhancement New feature or request package:dev

Comments

@sergiodxa
Copy link
Member

sergiodxa commented Dec 19, 2021

What version of Remix are you using?

Latest

What version of Node are you using? Minimum supported version is 14.

Any version

Steps to Reproduce

  • Create a context inside the root route and export it
  • In the root component render the provider of the context
  • In another root import that context and use it with useContext

Expected Behavior

It should either not duplicate the code or throw an error if you import from another route.

Actual Behavior

You don’t see any error or warning, and the useContext will not return the value the Provider received.

@sergiodxa sergiodxa added the bug Something isn't working label Dec 19, 2021
@geocine
Copy link

geocine commented Dec 20, 2021

Have you tried creating the context outside of the routes folder and importing it accordingly to your routes?

@sergiodxa
Copy link
Member Author

Have you tried creating the context outside of the routes folder and importing it accordingly to your routes?

Yes, that’s what I always recommend everyone with this issue, I didn’t opened the issue because I have the problem but because a lot of people do this.

@chaance chaance added enhancement New feature or request and removed bug Something isn't working labels Jun 5, 2022
@machour machour changed the title [Bug]: Importing from another route duplicates code Importing from another route shouldn't duplicate code Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request package:dev
Projects
None yet
Development

No branches or pull requests

4 participants