Closed joan-saum closed 5 years ago
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 https://github.com/necolas/react-native-web/issues/1354
I fix my problem by adding a default export in react-native-web. (copy and paste the change on this PR: https://github.com/necolas/react-native-web/pull/1277)
Not sure why the default export has been removed ?
react-native-codepush doesn't support the web as a platform
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
butReact.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.jsThen 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 ofreact-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?