66 * @flow strict-local
77 */
88
9- import React from 'react' ;
9+ import * as React from 'react' ;
10+ import { useRef , useState } from 'react' ;
1011import type { Node } from 'react' ;
1112import NativeAnswerSolver from './js/NativeAnswerSolver' ;
1213import {
@@ -27,6 +28,8 @@ import {
2728 ReloadInstructions ,
2829} from 'react-native/Libraries/NewAppScreen' ;
2930import Button from "react-native/Libraries/Components/Button" ;
31+ import AnswerViewer , { Commands as AnswerViewerCommands } from './js/NativeAnswerViewer' ;
32+ import type { AnswerViewerViewType } from './js/NativeAnswerViewer' ;
3033
3134const Section = ( { children, title} ) : Node => {
3235 const isDarkMode = useColorScheme ( ) === 'dark' ;
@@ -61,15 +64,21 @@ const App: () => Node = () => {
6164 backgroundColor : isDarkMode ? Colors . darker : Colors . lighter ,
6265 } ;
6366
67+ const ref = useRef < React . ElementRef < AnswerViewerViewType > | null > ( null ) ;
68+ const [ step , setStep ] = useState ( 1 ) ;
69+
6470 const onPress = ( ) => {
6571 const theAnswer = NativeAnswerSolver ?. answerTheUltimateQuestion ( "What's the Answer to the Ultimate Question of Life, the Universe, and Everything" ) || ""
6672 console . log ( 'The answer is: ' + theAnswer ) ;
73+ setStep ( step + 1 ) ;
74+ AnswerViewerCommands . changeBackgroundColor ( ref . current , "red" ) ;
6775 } ;
6876
6977 return (
7078 < SafeAreaView style = { backgroundStyle } >
7179 < StatusBar barStyle = { isDarkMode ? 'light-content' : 'dark-content' } />
7280 < Button title = "Click to invoke your Turbo Module!" onPress = { onPress } />
81+ < AnswerViewer ref = { ref } style = { { width : "100%" , height : 50 } } color = "yellow" step = { step } />
7382 < ScrollView
7483 contentInsetAdjustmentBehavior = "automatic"
7584 style = { backgroundStyle } >
0 commit comments