@@ -40,7 +40,7 @@ export const EngineView: FunctionComponent<EngineViewProps> = (props: EngineView
40
40
const [ appState , setAppState ] = useState ( AppState . currentState ) ;
41
41
const [ fps , setFps ] = useState < number > ( ) ;
42
42
const engineViewRef = useRef < Component < NativeEngineViewProps > > ( null ) ;
43
- const snapshotPromise = useRef < { promise : Promise < string > , resolve : ( data : string ) => void } > ( ) ;
43
+ const snapshotPromise = useRef < { promise : Promise < string > , resolve : ( data : string ) => void } > ( ) ;
44
44
45
45
useEffect ( ( ) => {
46
46
( async ( ) => {
@@ -80,6 +80,8 @@ export const EngineView: FunctionComponent<EngineViewProps> = (props: EngineView
80
80
} ;
81
81
}
82
82
}
83
+
84
+ return undefined ;
83
85
} , [ props . camera , appState ] ) ;
84
86
85
87
useEffect ( ( ) => {
@@ -99,6 +101,7 @@ export const EngineView: FunctionComponent<EngineViewProps> = (props: EngineView
99
101
}
100
102
101
103
setFps ( undefined ) ;
104
+ return undefined ;
102
105
} , [ props . camera , props . displayFrameRate ] ) ;
103
106
104
107
// Call onInitialized if provided, and include the callback for takeSnapshot.
@@ -134,7 +137,8 @@ export const EngineView: FunctionComponent<EngineViewProps> = (props: EngineView
134
137
135
138
// Handle snapshot data returned.
136
139
const snapshotDataReturnedHandler = useCallback ( ( event : SyntheticEvent ) => {
137
- const { data } = event . nativeEvent ;
140
+ // The nativeEvent is a DOMEvent which doesn't have a typescript definition. Cast it to an Event object with a data property.
141
+ const { data } = event . nativeEvent as Event & { data : string } ;
138
142
if ( snapshotPromise . current ) {
139
143
snapshotPromise . current . resolve ( data ) ;
140
144
snapshotPromise . current = undefined ;
@@ -143,9 +147,9 @@ export const EngineView: FunctionComponent<EngineViewProps> = (props: EngineView
143
147
144
148
if ( ! failedInitialization ) {
145
149
return (
146
- < View style = { [ props . style , { overflow : "hidden" } ] } >
147
- < NativeEngineView ref = { engineViewRef } style = { { flex : 1 } } onSnapshotDataReturned = { snapshotDataReturnedHandler } />
148
- { fps && < Text style = { { color : 'yellow' , position : 'absolute' , margin : 10 , right : 0 , top : 0 } } > FPS: { Math . round ( fps ) } </ Text > }
150
+ < View style = { [ props . style , { overflow : "hidden" } ] } >
151
+ < NativeEngineView ref = { engineViewRef } style = { { flex : 1 } } onSnapshotDataReturned = { snapshotDataReturnedHandler } />
152
+ { fps && < Text style = { { color : 'yellow' , position : 'absolute' , margin : 10 , right : 0 , top : 0 } } > FPS: { Math . round ( fps ) } </ Text > }
149
153
</ View >
150
154
) ;
151
155
} else {
@@ -155,9 +159,9 @@ export const EngineView: FunctionComponent<EngineViewProps> = (props: EngineView
155
159
}
156
160
157
161
return (
158
- < View style = { { flex : 1 , justifyContent : 'center' , alignItems : 'center' } } >
159
- < Text style = { { fontSize : 24 } } > { message } </ Text >
160
- { isRemoteDebuggingEnabled && < Text style = { { fontSize : 12 } } > React Native remote debugging does not work with Babylon Native.</ Text > }
162
+ < View style = { { flex : 1 , justifyContent : 'center' , alignItems : 'center' } } >
163
+ < Text style = { { fontSize : 24 } } > { message } </ Text >
164
+ { isRemoteDebuggingEnabled && < Text style = { { fontSize : 12 } } > React Native remote debugging does not work with Babylon Native.</ Text > }
161
165
</ View >
162
166
) ;
163
167
}
0 commit comments