File tree 2 files changed +24
-4
lines changed
2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
- import { Text , View } from 'react-native' ;
2
+ import { Text , View , Button } from 'react-native' ;
3
3
4
4
// eslint-disable-next-line import/no-unresolved, import/extensions
5
5
import ImmutableListView from 'react-native-immutable-list-view/src/ImmutableListView' ;
6
6
7
7
import style from './styles' ;
8
- import listData from './listData' ;
8
+ import mockData from './listData' ;
9
9
10
10
class App extends Component {
11
11
12
+ state = {
13
+ listData : mockData ,
14
+ } ;
15
+
16
+ changeData ( ) {
17
+ this . setState ( {
18
+ listData : mockData . setIn ( [ 'Section A' , 1 ] , 'This value was changed!' ) ,
19
+ } ) ;
20
+ }
21
+
12
22
renderRow ( rowData ) {
13
23
return < Text style = { style . row } > { JSON . stringify ( rowData ) } </ Text > ;
14
24
}
@@ -23,8 +33,14 @@ class App extends Component {
23
33
< Text style = { style . welcome } >
24
34
Welcome to React Native!
25
35
</ Text >
36
+ < View style = { style . button } >
37
+ < Button
38
+ onPress = { ( ) => this . changeData ( ) }
39
+ title = "Update Data"
40
+ />
41
+ </ View >
26
42
< ImmutableListView
27
- immutableData = { listData }
43
+ immutableData = { this . state . listData }
28
44
renderRow = { this . renderRow }
29
45
renderSectionHeader = { this . renderSectionHeader }
30
46
/>
Original file line number Diff line number Diff line change @@ -10,7 +10,11 @@ const style = StyleSheet.create({
10
10
welcome : {
11
11
fontSize : 20 ,
12
12
textAlign : 'center' ,
13
- margin : 10 ,
13
+ margin : 20 ,
14
+ } ,
15
+ button : {
16
+ padding : 20 ,
17
+ paddingTop : 0 ,
14
18
} ,
15
19
row : {
16
20
fontSize : 13 ,
You can’t perform that action at this time.
0 commit comments