Browse Source

Fix crash on collapsible click

Arnaud Vergnet 3 years ago
parent
commit
5166e0b879

+ 10
- 7
src/components/Animations/AnimatedAccordion.js View File

57
   }
57
   }
58
 
58
 
59
   setupChevron() {
59
   setupChevron() {
60
-    const {state} = this;
61
-    if (state.expanded) {
60
+    const {expanded} = this.state;
61
+    if (expanded) {
62
       this.chevronIcon = 'chevron-up';
62
       this.chevronIcon = 'chevron-up';
63
       this.animStart = '180deg';
63
       this.animStart = '180deg';
64
       this.animEnd = '0deg';
64
       this.animEnd = '0deg';
70
   }
70
   }
71
 
71
 
72
   toggleAccordion = () => {
72
   toggleAccordion = () => {
73
-    const {state} = this;
73
+    const {expanded} = this.state;
74
     if (this.chevronRef.current != null) {
74
     if (this.chevronRef.current != null) {
75
       this.chevronRef.current.transitionTo({
75
       this.chevronRef.current.transitionTo({
76
-        rotate: state.expanded ? this.animStart : this.animEnd,
76
+        rotate: expanded ? this.animStart : this.animEnd,
77
       });
77
       });
78
-      this.setState({expanded: !state.expanded});
78
+      this.setState((prevState: StateType): {expanded: boolean} => ({
79
+        expanded: !prevState.expanded,
80
+      }));
79
     }
81
     }
80
   };
82
   };
81
 
83
 
87
         <List.Item
89
         <List.Item
88
           title={props.title}
90
           title={props.title}
89
           subtitle={props.subtitle}
91
           subtitle={props.subtitle}
90
-          titleStyle={state.expanded ? {color: colors.primary} : undefined}
92
+          titleStyle={state.expanded ? {color: colors.primary} : null}
91
           onPress={this.toggleAccordion}
93
           onPress={this.toggleAccordion}
92
           right={({size}: {size: number}): React.Node => (
94
           right={({size}: {size: number}): React.Node => (
93
             <AnimatedListIcon
95
             <AnimatedListIcon
94
               ref={this.chevronRef}
96
               ref={this.chevronRef}
95
               size={size}
97
               size={size}
96
               icon={this.chevronIcon}
98
               icon={this.chevronIcon}
97
-              color={state.expanded ? colors.primary : undefined}
99
+              color={state.expanded ? colors.primary : null}
98
               useNativeDriver
100
               useNativeDriver
101
+              style={{rotate: '0deg'}}
99
             />
102
             />
100
           )}
103
           )}
101
           left={props.left}
104
           left={props.left}

+ 0
- 1
src/components/Lists/PlanexGroups/GroupListAccordion.js View File

96
           }
96
           }
97
           unmountWhenCollapsed // Only render list if expanded for increased performance
97
           unmountWhenCollapsed // Only render list if expanded for increased performance
98
           opened={props.item.id === 0 || props.currentSearchString.length > 0}>
98
           opened={props.item.id === 0 || props.currentSearchString.length > 0}>
99
-          {/* $FlowFixMe */}
100
           <FlatList
99
           <FlatList
101
             data={this.getData()}
100
             data={this.getData()}
102
             extraData={props.currentSearchString}
101
             extraData={props.currentSearchString}

Loading…
Cancel
Save