Reputation: 442
As mentioned in the title, I wanna change the android entry file(index.android.js) and iOS entry file(index.ios.js) to a common js file named index.js
, How do I modify in project?
Upvotes: 2
Views: 426
Reputation: 5193
We cannot achieve that currently. We will get the following error if we try to do so.
One way to simulate single entry point is by creating a container component having a single entry point your application like below
Application.js
import React from 'react';
import {
Component,
View,
Text,
} from 'react-native';
class Application extends Component {
render() {
return (
<View><Text>Hello world</Text></View>
);
}
}
module.exports = Application;
and copy paste the same contents in index.ios.js and index.android.js
import {
AppRegistry,
} from 'react-native';
import Application from './Application';
AppRegistry.registerComponent('YourAppName', () => Application);
Upvotes: 3