-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
react native and mobx 6.x with TypeScript and Babel recommend options cause network request without any response #3100
Comments
I can't imagine how a compilation of your sources could affect behavior of |
@urugator error like that, but it still appears when i remove the recommend options. |
Ok, so do I understand correctly, it's not related to mobx and therefore the issue can be closed here? You may want to check: |
emmmm, sorry about that, i have searched more before, but still cant find solution, may be its not mobx`s problem, but on new RN project without any packages and options, it work well as expect until add mobx and those recommend option. and if its only matter of debugger, when i close debugger and even release to apk, it still not work. i am confused. |
Hi @woowalker! I think finded solution. Add this to babel config: ...
overrides: [
{
test: fileName => !fileName.includes('node_modules'),
plugins: [[require('@babel/plugin-proposal-class-properties'), { loose: false }]],
},
],
... |
sorry to reopen this issue, i try my hard, but it still happened. @enniel and sorry, it not work for me. but i found an solution, set babel config to
it works, and #3102 fast refresh work again. |
@woowalker could you also try to combine them like this: overrides: [
{
test: fileName => !fileName.includes('node_modules'),
plugins: [
['@babel/plugin-transform-flow-strip-types'],
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: false }],
],
},
], and like this: plugins: [
['@babel/plugin-transform-flow-strip-types']
],
overrides: [
{
test: fileName => !fileName.includes('node_modules'),
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
['@babel/plugin-proposal-class-properties', { loose: false }],
],
},
], ? |
Hello, I'm confused, I'm trying to add this configuration but the second I do, I get another issue about "undefined is not an object (evaluating 'props.getItem')". As explained here, this happens by adding ['@babel/plugin-proposal-class-properties', { loose: false }] in plugins or overrides. How can I make this work? Thank you |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
@randomtoni did you got any solution ? |
@siddharth-kt I was having a configuration issue but it really took me a long time to figure it out. I tried many many things, so I'm not able to tell you what really solved the issue. This is my last and working configuration for babel
|
@randomtoni Thanks, as i see you remove "plugins": [["@babel/plugin-proposal-class-properties", { "loose": false }]], |
everything has been working without any issues for a while now. A a general rule, I always clear the cache between configs changes (react-native start --reset-cache), sometimes it didn't picked up the differences. |
One more thing. That was my config for react-native, for a react project I ended up using
|
@randomtoni yeah its implemented here. |
Dropping this here just in case you're using Nx, this is the babel config that worked for me:
babel version: 7.18.6 |
How to reproduce the issue:
![image](https://user-images.githubusercontent.com/7894779/131488059-9de253bc-95f9-43f3-b23b-fdfd76a0a15e.png)
![image](https://user-images.githubusercontent.com/7894779/131488134-01e3f523-e192-4218-9deb-84c5a559c1f1.png)
![image](https://user-images.githubusercontent.com/7894779/131488469-4b1b9efb-a98e-48d5-be2a-fc850f91e267.png)
npx react-native init MyApp --template react-native-template-typescript
yarn add mobx mobx-react
babel.config.js
module.exports = { presets: ['module:metro-react-native-babel-preset'], plugins: [ [ '@babel/plugin-proposal-class-properties', { loose: false, }, ], ], assumptions: { setPublicClassFields: false, }, };
tsconfig.json
{"compilerOptions": { "useDefineForClassFields": true, ...others }}
App.tsx
get rid off those options
Versions
The text was updated successfully, but these errors were encountered: