-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
Add Web Support #45
Add Web Support #45
Conversation
Hi! Thanks for the PR! I've never used RN Web before - how do I test this out? Could you also add a web app to the example/ so I can test it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments, once those are fixed and I have a react-native-web example in the example/
folder we can merge this 👍
Made suggested changes @mrousavy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay I have left a few nitpicking comments, I'd like them to be resolved (only affects example). After that, I think everything looks perfect 👌
I made the further suggested edits. |
So I ran the App for iOS and Android and nothing seems to be broken there, so that's good. However, when I run
|
Actually the native app also breaks by this PR. This must be some issue with the new babel config:
A quick stackoverflow search showed me a possible approach, however I don't think that is a solution but rather a wacky workaround. Can we make the babel config only apply to the web project and leave the normal config for the native apps as is? Surely react-native-web has a solution for this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my 2 comments above.
- Can't run
yarn web
to see the app. - Native example app breaks because of the babel config changes.
@@ -112,6 +113,9 @@ | |||
"useTabs": false | |||
} | |||
] | |||
}, | |||
"globals": { | |||
"localStorage": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially better to add /* global localStorage */
to the top of src/index.web.ts
, since it's only available as a global on the web platform, and not to the rest of the code...
@@ -53,6 +53,7 @@ | |||
"@react-native-community/eslint-config": "^2.0.0", | |||
"@release-it/conventional-changelog": "^2.0.0", | |||
"@types/jest": "^26.0.0", | |||
"@types/node": "^14.14.37", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry if I'm missing something obvious, but I cannot find where these types are used?
Types in the @types/node
package are only available when running inside Node.js, not in the browser which this new code is targeting, right?
I think it would be easier to have a separate example folder for web, and just use a minimal expo web template. |
RN MMKV now supports web 🎉 |
Addressing suggestion in #11 with localStorage support.