From 03cb5aca3f5b8594287608265d4bde7104f07b87 Mon Sep 17 00:00:00 2001 From: Pieter Vanderwerff Date: Thu, 15 Sep 2022 11:03:03 -0700 Subject: [PATCH] Improve sample app Summary: Improve RN sample application code quality. Reviewed By: mroch Differential Revision: D39488055 fbshipit-source-id: f6056c0790d6fee473a57b9d29a0ce21841f63c1 --- template/App.js | 55 +++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/template/App.js b/template/App.js index 4c97733b30cab9..885fef81169fb3 100644 --- a/template/App.js +++ b/template/App.js @@ -26,9 +26,31 @@ import { ReloadInstructions, } from 'react-native/Libraries/NewAppScreen'; -/* $FlowFixMe[missing-local-annot] The type annotation(s) required by Flow's - * LTI update could not be added via codemod */ -const Section = ({children, title}): Node => { +const styles = StyleSheet.create({ + sectionContainer: { + marginTop: 32, + paddingHorizontal: 24, + }, + sectionTitle: { + fontSize: 24, + fontWeight: '600', + }, + sectionDescription: { + marginTop: 8, + fontSize: 18, + fontWeight: '400', + }, + highlight: { + fontWeight: '700', + }, +}); + +type SectionProps = { + title: string, + children: Node, +}; + +function Section({children, title}: SectionProps): Node { const isDarkMode = useColorScheme() === 'dark'; return ( @@ -52,9 +74,9 @@ const Section = ({children, title}): Node => { ); -}; +} -const App: () => Node = () => { +export default function App(): Node { const isDarkMode = useColorScheme() === 'dark'; const backgroundStyle = { @@ -93,25 +115,4 @@ const App: () => Node = () => { ); -}; - -const styles = StyleSheet.create({ - sectionContainer: { - marginTop: 32, - paddingHorizontal: 24, - }, - sectionTitle: { - fontSize: 24, - fontWeight: '600', - }, - sectionDescription: { - marginTop: 8, - fontSize: 18, - fontWeight: '400', - }, - highlight: { - fontWeight: '700', - }, -}); - -export default App; +}