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

Try to move upstream ejected HelloWorld template to a single index.js entry point #26

Closed
anp opened this issue Feb 8, 2017 · 7 comments

Comments

@anp
Copy link
Contributor

anp commented Feb 8, 2017

The HelloWorld template project in react-native/local-cli currently assumes that there will be two entry points: index.ios.js and index.android.js. CRNA projects start with a single main.js (although this is fungible and could easily be called index.js), which breaks on iOS (haven't tested Android) once ejected to a regular RN project.

For now I'm implementing some dirty hacks around this, but would like to make the upstream template project(s) compatible with CRNA's eject in the near term. I think this will just require a PR that I don't have bandwidth to write and push through right now.

EDIT: this wouldn't just require unifying the files, it looks like test and example code (and maybe docs?) assume that these files will be separate.

@anp anp added the help wanted label Feb 8, 2017
@mkonicek
Copy link

mkonicek commented Feb 10, 2017

I like main.js better than index.js actually! Index is so webby :)

But actually we're trying to bring RN and web development closer together, so let's keep index. Also people are kind of used to it by now.

@mkonicek mkonicek self-assigned this Feb 10, 2017
@anp
Copy link
Contributor Author

anp commented Feb 10, 2017

:D I should note that I moved the CRNA template to index.js to match up with the dirty hack I wrote for providing the HelloWorld template with index.(ios|android).js files. Can definitely change it back!

@mkonicek
Copy link

Cool I'll update the template.

@mkonicek
Copy link

index.js is good (edited my comment above) 👍

@anp
Copy link
Contributor Author

anp commented Feb 17, 2017

@mkonicek does this seem like something likely to make it into 0.42?

@brentvatne brentvatne assigned fson and unassigned mkonicek Jul 25, 2017
@fson
Copy link
Contributor

fson commented Jul 28, 2017

I'm working on a pull request to make this change to the HelloWorld template in react-native and all the tests and docs that refer to the old index.ios.js/index.android.js files.

@fson
Copy link
Contributor

fson commented Aug 1, 2017

I've made the upstream changes here: facebook/react-native#15312.

facebook-github-bot pushed a commit to facebook/react-native that referenced this issue Aug 3, 2017
Summary:
This change (initially discussed in expo/create-react-native-app#26) moves the HelloWorld project template from two nearly identical entry points (`index.android.js` and `index.ios.js`) to a single, minimal `index.js` entry point. The root component is created in `App.js`. This unifies the project structure between `react-native init` and Create React Native App and allows CRNA's eject to use the entry point from the HelloWorld template without any hacks to customize it. Also examples in the docs can be just copy-pasted to `App.js` the same way in both HelloWorld and CRNA apps without having to first learn about  `AppRegistry.registerComponent`.

* Created a new project from the template using `./scripts/test-manual-e2e.sh` and verified that:
  * The app builds, starts and runs both on Android and iOS.
  * Editing and reloading changes works.
  * The new files (`index.js`, `App.js`, `__tests__/App.js`) get created in the project folder.

<img width="559" alt="screen shot 2017-08-01 at 19 10 51" src="https://user-images.githubusercontent.com/497214/28835171-300a12b6-76ed-11e7-81b2-623639c3b8f6.png">
<img width="467" alt="screen shot 2017-08-01 at 19 09 12" src="https://user-images.githubusercontent.com/497214/28835180-33d285e0-76ed-11e7-8d68-2b3bc44bf585.png">

<!--
Thank you for sending the PR!

If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos!

Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native.

Happy contributing!
-->
Closes #15312

Differential Revision: D5556276

Pulled By: hramos

fbshipit-source-id: 068fdf7e51381c2bc50321522f2be0db47296c5e
grabbou pushed a commit to react-native-community/cli that referenced this issue Sep 26, 2018
Summary:
This change (initially discussed in expo/create-react-native-app#26) moves the HelloWorld project template from two nearly identical entry points (`index.android.js` and `index.ios.js`) to a single, minimal `index.js` entry point. The root component is created in `App.js`. This unifies the project structure between `react-native init` and Create React Native App and allows CRNA's eject to use the entry point from the HelloWorld template without any hacks to customize it. Also examples in the docs can be just copy-pasted to `App.js` the same way in both HelloWorld and CRNA apps without having to first learn about  `AppRegistry.registerComponent`.

* Created a new project from the template using `./scripts/test-manual-e2e.sh` and verified that:
  * The app builds, starts and runs both on Android and iOS.
  * Editing and reloading changes works.
  * The new files (`index.js`, `App.js`, `__tests__/App.js`) get created in the project folder.

<img width="559" alt="screen shot 2017-08-01 at 19 10 51" src="https://user-images.githubusercontent.com/497214/28835171-300a12b6-76ed-11e7-81b2-623639c3b8f6.png">
<img width="467" alt="screen shot 2017-08-01 at 19 09 12" src="https://user-images.githubusercontent.com/497214/28835180-33d285e0-76ed-11e7-8d68-2b3bc44bf585.png">

<!--
Thank you for sending the PR!

If you changed any code, please provide us with clear instructions on how you verified your changes work. In other words, a test plan is *required*. Bonus points for screenshots and videos!

Please read the Contribution Guidelines at https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md to learn more about contributing to React Native.

Happy contributing!
-->
Closes facebook/react-native#15312

Differential Revision: D5556276

Pulled By: hramos

fbshipit-source-id: 068fdf7e51381c2bc50321522f2be0db47296c5e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants