MCPcopy Create free account
hub / github.com/dabbott/react-native-express / App

Function App

examples/files/core_components/flexbox.js:6–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4import Toggle from './Toggle'
5
6export default function App() {
7 const [flexDirection, setFlexDirection] = useState('row')
8 const [justifyContent, setJustifyContent] = useState('center')
9 const [alignItems, setAlignItems] = useState('center')
10 const layoutStyle = { flexDirection, justifyContent, alignItems }
11
12 const primaryAxis = flexDirection === 'row' ? 'Horizontal' : 'Vertical'
13 const secondaryAxis = flexDirection === 'row' ? 'Vertical' : 'Horizontal'
14
15 return (
16 <View style={styles.container}>
17 <Toggle
18 label={'Primary axis (flexDirection)'}
19 value={flexDirection}
20 options={flexDirectionOptions}
21 onChange={(option) => {
22 setFlexDirection(option)
23 }}
24 />
25 <Toggle
26 label={`${primaryAxis} distribution (justifyContent)`}
27 value={justifyContent}
28 options={justifyContentOptions}
29 onChange={(option) => {
30 setJustifyContent(option)
31 }}
32 />
33 <Toggle
34 label={`${secondaryAxis} alignment (alignItems)`}
35 value={alignItems}
36 options={alignItemsOptions}
37 onChange={(option) => {
38 setAlignItems(option)
39 }}
40 />
41 <View style={[styles.layout, layoutStyle]}>
42 <View style={styles.box} />
43 <View style={styles.box} />
44 <View style={styles.box} />
45 </View>
46 </View>
47 )
48}
49
50const flexDirectionOptions = ['row', 'column']
51const justifyContentOptions = [

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected