@@ -111,36 +111,38 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps) => {
111
111
break ;
112
112
}
113
113
114
- fluentUIThemeInstanceRef . current = convertFromPartialThemeToTheme ( theme ) ;
114
+ let currentTheme = convertFromPartialThemeToTheme ( theme ) ;
115
+ fluentUIThemeInstanceRef . current = currentTheme ;
115
116
116
117
let hostConfig = props . hostConfig ;
117
118
if ( ! hostConfig ) {
118
119
switch ( themeType ) {
119
120
case AdaptiveCardHostThemeType . SharePoint : {
120
- hostConfig = createSharePointHostConfig ( fluentUIThemeInstanceRef . current ) ;
121
+ hostConfig = createSharePointHostConfig ( currentTheme ) ;
121
122
}
122
123
break ;
123
124
case AdaptiveCardHostThemeType . Teams : {
124
- hostConfig = createDefaultTeamsHostConfig ( fluentUIThemeInstanceRef . current ) ;
125
+ hostConfig = createDefaultTeamsHostConfig ( currentTheme ) ;
125
126
}
126
127
break ;
127
128
case AdaptiveCardHostThemeType . TeamsDark : {
128
- hostConfig = createDarkTeamsHostConfig ( fluentUIThemeInstanceRef . current ) ;
129
+ hostConfig = createDarkTeamsHostConfig ( currentTheme ) ;
129
130
}
130
131
break ;
131
132
case AdaptiveCardHostThemeType . TeamsHighContrast : {
132
- hostConfig = createHighContrastTeamsHostConfig ( fluentUIThemeInstanceRef . current ) ;
133
+ hostConfig = createHighContrastTeamsHostConfig ( currentTheme ) ;
133
134
}
134
135
break ;
135
136
}
136
137
}
137
138
138
- adaptiveCardInstanceRef . current . hostConfig = new HostConfig ( hostConfig ) ;
139
+ let currentHostConfig = new HostConfig ( hostConfig ) ;
140
+ adaptiveCardInstanceRef . current . hostConfig = currentHostConfig ;
139
141
140
- setFluentUIThemeAsHostCapability ( adaptiveCardInstanceRef . current . hostConfig , fluentUIThemeInstanceRef . current ) ;
142
+ setFluentUIThemeAsHostCapability ( currentHostConfig , currentTheme ) ;
141
143
142
144
if ( props . onUpdateHostCapabilities ) {
143
- props . onUpdateHostCapabilities ( adaptiveCardInstanceRef . current . hostConfig . hostCapabilities ) ;
145
+ props . onUpdateHostCapabilities ( currentHostConfig . hostCapabilities ) ;
144
146
}
145
147
146
148
setFluentUIThemeAsCSSVariables (
@@ -182,21 +184,22 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps) => {
182
184
props . onSetCustomActions ( actionRegistry ) ;
183
185
}
184
186
185
- serializationContextInstanceRef . current . setElementRegistry ( elementRegistry ) ;
186
- serializationContextInstanceRef . current . setActionRegistry ( actionRegistry ) ;
187
+ let currentSerializationContext = serializationContextInstanceRef . current ;
188
+ currentSerializationContext . setElementRegistry ( elementRegistry ) ;
189
+ currentSerializationContext . setActionRegistry ( actionRegistry ) ;
187
190
188
191
} , [ serializationContextInstanceRef . current ] ) ;
189
192
// *****
190
193
191
194
// set Adaptive Card
192
195
useEffect ( ( ) => {
193
- if ( ! renderElementRef . current ) {
196
+ let currentRenderElement = renderElementRef . current ;
197
+
198
+ if ( ! currentRenderElement ) {
194
199
return ;
195
200
}
196
201
197
- let adaptiveCard = adaptiveCardInstanceRef . current ;
198
- let serializationContext = serializationContextInstanceRef . current ;
199
-
202
+ let currentAdaptiveCard = adaptiveCardInstanceRef . current ;
200
203
try {
201
204
let cardPayload ;
202
205
if ( props . data ) {
@@ -207,11 +210,11 @@ export const AdaptiveCardHost = (props: IAdaptiveCardHostProps) => {
207
210
cardPayload = props . card ;
208
211
}
209
212
210
- adaptiveCard . parse ( cardPayload , serializationContext ) ;
213
+ currentAdaptiveCard . parse ( cardPayload , serializationContextInstanceRef . current ) ;
211
214
212
- let renderedElement = adaptiveCard . render ( ) ;
213
- renderElementRef . current . innerHTML = "" ;
214
- renderElementRef . current . appendChild ( renderedElement ) ;
215
+ let renderedElement = currentAdaptiveCard . render ( ) ;
216
+ currentRenderElement . innerHTML = "" ;
217
+ currentRenderElement . appendChild ( renderedElement ) ;
215
218
} catch ( cardRenderError ) {
216
219
if ( props . onError ) {
217
220
props . onError ( cardRenderError ) ;
0 commit comments