File tree Expand file tree Collapse file tree 3 files changed +24
-17
lines changed Expand file tree Collapse file tree 3 files changed +24
-17
lines changed Original file line number Diff line number Diff line change 1- import React from 'react'
2- import { StyleSheet , Text , View } from 'react-native'
1+ import React , { useState } from 'react'
2+ import { StyleSheet , View } from 'react-native'
33
4- export default class App extends React . Component {
5- state = {
6- counter : 0
7- }
4+ import Counter from './Counter'
85
9- render ( ) {
10- return (
11- < View style = { styles . container } >
12- < Text style = { styles . mainText } > Counter: { this . state . counter } </ Text >
13- </ View >
14- )
15- }
6+ export default function App ( ) {
7+ const [ counter , setCounter ] = useState ( 0 )
8+ return (
9+ < View style = { styles . container } >
10+ < Counter counter = { counter } / >
11+ </ View >
12+ )
1613}
1714
1815const styles = StyleSheet . create ( {
@@ -21,9 +18,5 @@ const styles = StyleSheet.create({
2118 backgroundColor : '#fff' ,
2219 alignItems : 'center' ,
2320 justifyContent : 'center'
24- } ,
25- mainText : {
26- backgroundColor : '#5CA2FA' ,
27- padding : 20
2821 }
2922} )
Original file line number Diff line number Diff line change 1+ import React from 'react'
2+ import { StyleSheet , Text } from 'react-native'
3+
4+ export default function Counter ( props ) {
5+ return < Text style = { styles . mainText } > Counter:{ props . counter } </ Text >
6+ }
7+
8+ const styles = StyleSheet . create ( {
9+ mainText : {
10+ backgroundColor : '#5CA2FA' ,
11+ padding : 20
12+ }
13+ } )
Original file line number Diff line number Diff line change @@ -13,3 +13,4 @@ You can check the commits to find the part by part codes.
1313- [ Day 1 - React Native Intro] ( https://www.instagram.com/p/B-EsmshATpS/ )
1414- [ Day 2 - Stylesheet in React Native] ( https://www.instagram.com/p/B-JxJdzlf5E/ )
1515- [ Day 3 - State in React Native] ( https://www.instagram.com/p/B-PK5LmAkKi/ )
16+ - [ Day 4 - Props in React Native] ( https://www.instagram.com/p/B-UFIC2gyIl/ )
You can’t perform that action at this time.
0 commit comments