-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
Replace new app template with new app screen #24805
Replace new app template with new app screen #24805
Conversation
So this ends up clocking in at ~120 lines of code, which is over our ideal new app template of ~35-45 LoC. One thought I have is to pull out the reload and debug instructions into the My second thought is to turn I'm keen on some other ideas on how to reduce the lines of code here too! |
I don't know where the number comes from but 30-40 LOC of the JSX in the render I think is totally fine 👍 Whether there value in having the two platform-y functions is a good Q - but I'm pretty happy with the rest of the code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree we should trim it down. Let's tuck ReloadInstructions and DebugInstructions into the NewAppScreen and also put those sections into the LeanMoreLinks
component (possibly named differently?). In terms of size that should trim it enough to be small but it will still have View/Text in it. Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, meant to request changes :D
@orta I think this was an arbitrary number we pulled out that seems like it could be a good amount of code to leave as a first impression to RN. For some context, create-react-app's template clocks in at 26LoC, granted their styling is imported from a CSS module: https://github.com/facebook/create-react-app/blob/e2f43a06a60646f2db00ff0558acb6d2a3355a36/packages/react-scripts/template/src/App.js I'll move stuff around like @cpojer recommended and we'll see how that feels! |
This will abstract over the platform checks and reduce the amount of hard coded copy we have in the initial app template.
a0f0708
to
b266a5c
Compare
Done in b266a5c
Hmmmm, I'm not sure how this would work, without losing all the <Fragment>
<StatusBar/>
<ScrollView>
<Header />
<View>{/* Sections with title & descriptions */}
<Section>
<Text />
<Text />
</Section>
<Section>
<Text />
<Text>
<ReloadInstructions />
</Text>
</Section>
<Section>
<Text />
<Text>
<DebugInstructions />
</Text>
</Section>
<Section>
<Text />
<Text />
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</Fragment>; In order to move @cpojer can you explain your thought process on how to move Reload and Debug into LearnMore for me? |
Right now it looks like this: <Section>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</Section>
<Section>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</Section>
<Section>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</Section>
<Section>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs on what to do once seen how to work in React Native.
</Text>
</Section>
<LearnMoreLinks /> I think a bunch of this is superfluous. We only need a single <Section>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Text>
</Section>
<LearnMoreLinks /> {/* Everything removed compared to above is inside this component know */} It still uses the same type of components as before at least once and is much much shorter in App.js. |
This component wasn’t really helpful to us, as it only applied a style that we could apply in render anyway.
This reduces duplicity in the new app screen, and makes it easier to understand what comes from this module.
b2f18f2
to
2bc2b1e
Compare
Colors, | ||
DebugInstructions, | ||
ReloadInstructions, | ||
} from 'react-native/Libraries/NewAppScreen'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this definitely needs an annotation that importing stuff from react-native/Libraries
is only for demonstration purposes and one should never do it in a real app because it may break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic! Thank you so much for the hard work on this. I'm going to land this version but we can update the comment in a follow-up.
@thymikee instead of a comment, what do you think of moving the index file of NewAppScript to react-native/NewAppScreen
? That way it should be clear not to reach into libraries as it special cases this file only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cpojer is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@cpojer makes sense |
This pull request was successfully merged by @eliperkins in fe88e9e. When will my fix make it into a release? | Upcoming Releases |
Summary
This replaces the "new app screen" in the template with the new design from react-native-community/discussions-and-proposals#122
This uses components that are shipped as part of the
react-native
module, but not necessarily as proper components exported by the mainreact-native
module. To use these, we use absolute imports to those components.Related to #24760
Changelog
[General] [Changed] - Updated new app template design 💖
Test Plan
git fetch origin pull/ID/head:BRANCHNAME && git checkout BRANCHNAME
, see also: https://help.github.com/en/articles/checking-out-pull-requests-locally).react-nativ
e field inreact-native/template/package.json
to the absolute path of the react native repo, for example:"react-native": "file:///Users/username/react-native"
.npx @react-native-community/cli@next init TestApp --template file:///Users/username/react-native
(If you don't havenpx
, runbrew install npm
).