-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 react component from parent directory breaks react hooks #2709
Comments
I believe this must be somehow related in .bashrc inheritance. Similar issues: And possible workaround: |
I got this as well when |
Update. It doesn't affect pure vanilla js projects. |
I'm not able to create simple typescript project as an example of this issue (but still have an issue in my original project). So closing until I manage to either publish my project or create similar affected by this issue. |
FWIW I'm not using TS, but these build systems are getting so complicated I have no clue what's going on haha, might not be Parcel related at all |
i feel you brother :) thank you for expressjs btw ;) |
@mauron85 could you re-open this issue? I've created a repo to reproduce this issue: https://github.com/imjared/parcel-js-react-hooks I'm on Mojave and using Node v10.13.0 |
@imjared create new one. |
🐛 bug report
First I would to say that I ❤️ parcel.
My problem is related to React 16.6.x hooks, but strangely it's only an issue when importing module from parent (eg.
../parent/module
). There are few more issues related to react-hot-loader and React 16.6.x hooks, but I promise this one is different :).Let's imagine following project structure of typescript project
From
playground/module2.ts
I'm importingmodule1.ts
(react component) that is located in parent dir (../src
). So import looks like:However compiled bundle is not usable. It triggers react error:
Error: Hooks can only be called inside the body of a function component.
Interesingly making symlink from
playground
directory to parentsrc
->ln -s ../src src
and importing same module as:
works just fine. Bundle doesn't trigger any error.
🎛 Configuration (.babelrc, package.json, cli command)
Playground doesn't have any .babelrc
Parent's .babel.rc
🤔 Expected Behavior
I believe, there should be no difference between
import from '../src
andimport from './src
as both contain uncompiled and unprocessed source typescript files.😯 Current Behavior
Importing react module relative to parent triggers error in the runtime:
💁 Possible Solution
Not sure. But as same problem is also in production variant, so it's not probably react-hot-loader issue (like this one gaearon/react-hot-loader#1088 (comment))
🔦 Context
Making symlink to parent dir as workaround is really strange.
Not sure.
💻 Code Sample
Can provide later.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: