Skip to content

Commit

Permalink
[Fabric] Use the new Fabric custom component
Browse files Browse the repository at this point in the history
  • Loading branch information
cortinico committed Feb 28, 2022
1 parent adeee8b commit 582a8a7
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* @flow strict-local
*/

import React from 'react';
import * as React from 'react';
import {useRef, useState} from 'react';
import type {Node} from 'react';
import NativeAnswerSolver from './js/NativeAnswerSolver';
import {
Expand All @@ -27,6 +28,8 @@ import {
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import Button from "react-native/Libraries/Components/Button";
import AnswerViewer, {Commands as AnswerViewerCommands} from './js/NativeAnswerViewer';
import type {AnswerViewerViewType} from './js/NativeAnswerViewer';

const Section = ({children, title}): Node => {
const isDarkMode = useColorScheme() === 'dark';
Expand Down Expand Up @@ -61,15 +64,21 @@ const App: () => Node = () => {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

const ref = useRef<React.ElementRef<AnswerViewerViewType> | null>(null);
const [step, setStep] = useState(1);

const onPress = () => {
const theAnswer = NativeAnswerSolver?.answerTheUltimateQuestion("What's the Answer to the Ultimate Question of Life, the Universe, and Everything") || ""
console.log('The answer is: ' + theAnswer);
setStep(step+1);
AnswerViewerCommands.changeBackgroundColor(ref.current, "red");
};

return (
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<Button title="Click to invoke your Turbo Module!" onPress={onPress} />
<AnswerViewer ref={ref} style={{width: "100%", height: 50}} color="yellow" step={step} />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
Expand Down

0 comments on commit 582a8a7

Please sign in to comment.