Skip to content
This repository was archived by the owner on Jul 1, 2025. It is now read-only.

Commit 582a8a7

Browse files
committed
[Fabric] Use the new Fabric custom component
1 parent adeee8b commit 582a8a7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

App.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
* @flow strict-local
77
*/
88

9-
import React from 'react';
9+
import * as React from 'react';
10+
import {useRef, useState} from 'react';
1011
import type {Node} from 'react';
1112
import NativeAnswerSolver from './js/NativeAnswerSolver';
1213
import {
@@ -27,6 +28,8 @@ import {
2728
ReloadInstructions,
2829
} from 'react-native/Libraries/NewAppScreen';
2930
import Button from "react-native/Libraries/Components/Button";
31+
import AnswerViewer, {Commands as AnswerViewerCommands} from './js/NativeAnswerViewer';
32+
import type {AnswerViewerViewType} from './js/NativeAnswerViewer';
3033

3134
const 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

Comments
 (0)