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

react native codepush using Alert #1366

Closed
joan-saum opened this issue Jun 11, 2019 · 3 comments
Closed

react native codepush using Alert #1366

joan-saum opened this issue Jun 11, 2019 · 3 comments

Comments

@joan-saum
Copy link

The problem
Hello!
I'm trying to be able to have my mobile app accessible through the web thanks to this repo.
I'm able to build the app, but when I launch the index.html created, i got some JS errors.

After inspection, I think I found the problem but I don't know how to solve it:
I'm using the react-native-codepush repo, and this use the Alert module from React like this:

import React, { Platform } from "react-native";
let { Alert } = React;

When trying to access to the Alert module, in the bundle.js, it try to do this :
React.default.Alert but React.default is undefined.

I tried to reimplement the Alert, i created an alias react-native-alert.js with the code from this reimplementing of Alert: https://github.com/Wildtyto/Alert7.js/blob/master/alert7.js

Then i created the alias react-native-web.js to include the Alert :

const ReactNative = require('react-native-web');
const Alert = require('./react-native-alert');

export default { ...ReactNative, Alert };

and in my webpack.config.js, I put the alias of react-native-web like :

resolve {
alias: {
'react-native$': path.resolve(__dirname, './aliases/react-native-web'),
}
}

But still not working.. Did someone try to do something like this?

  • React Native for Web (version): 0.11.2
  • React (version): 16.6.3
  • Browser: Firefox, Chrome
@vladp
Copy link

vladp commented Jun 14, 2019

As a test, did you try to use any other React-native library in your project, (for example react-native-vector-icons), or something else where the author 'officially' supports React-native only ?

If you try those libraries, and you are getting a similar error -- then it means something is wrong your bundler config, and not react-native-web.

It is not clear, but it seems that you are not even using CRA (Create React App), so you will have to search for boiler plate examples that go that route.
For example of similar types of issues, see
#1354

@joan-saum
Copy link
Author

I fix my problem by adding a default export in react-native-web.
(copy and paste the change on this PR: #1277)

Not sure why the default export has been removed ?

@necolas
Copy link
Owner

necolas commented Jun 28, 2019

react-native-codepush doesn't support the web as a platform

@necolas necolas closed this as completed Jun 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants