Example of how to use react-native-web with Parcel.js
npm install
npm run web
or for the standard Expo build:
npm run start
Run the standard create-react-native-app.
npm install --save parcel-bundler react-dom react-native-web
See the index.html file.
See .babelrc. When NODE_ENV
equals web
then babel will resolve to react-native-web instead of react-native.
Add npm run script: "web": "NODE_ENV=web parcel index.html",
...
import { AppRegistry } from 'react-native';
...
if (Platform.OS === 'web') {
AppRegistry.registerComponent('App', () => App);
AppRegistry.runApplication('App', {
initialProps: {},
rootTag: document.getElementById('root'),
});
}
npm run web