Skip to content

Commit

Permalink
add repro
Browse files Browse the repository at this point in the history
  • Loading branch information
mozzius committed Apr 18, 2024
1 parent 391eadd commit 38f56d7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 99 deletions.
129 changes: 31 additions & 98 deletions ReproducerApp/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,114 +5,47 @@
* @format
*/

import React from 'react';
import type {PropsWithChildren} from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';
import {useState} from 'react';
import {TextInput, View, SafeAreaView, Text} from 'react-native';

import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
export default function App() {
return (
<SafeAreaView style={{flex: 1}}>
<View style={{padding: 20, gap: 20}}>
<WithValueProp />
<WithoutValueProp />
</View>
</SafeAreaView>
);
}

type SectionProps = PropsWithChildren<{
title: string;
}>;
function WithValueProp() {
const [text, setText] = useState('');

function Section({children, title}: SectionProps): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
<View>
<TextInput
style={{height: 40, fontSize: 20}}
placeholder="Without value prop"
onChangeText={setText}
value={text}
/>
<Text>{text}</Text>
</View>
);
}

function App(): React.JSX.Element {
const isDarkMode = useColorScheme() === 'dark';

const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};
function WithoutValueProp() {
const [text, setText] = useState('');

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
backgroundColor={backgroundStyle.backgroundColor}
<View>
<TextInput
style={{height: 40, fontSize: 20}}
placeholder="Without value prop"
onChangeText={setText}
/>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.tsx</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
<Text>{text}</Text>
</View>
);
}

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;
3 changes: 2 additions & 1 deletion ReproducerApp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@
},
"engines": {
"node": ">=18"
}
},
"packageManager": "[email protected]+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447"
}

0 comments on commit 38f56d7

Please sign in to comment.