Migrate rn-tester/js/components/RNTesterTitle.js to function components (#48649)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/48649

As per title.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D68099051

fbshipit-source-id: 867010b692e6d71e4683cc12b4455be730413268
This commit is contained in:
Fabrizio Cucci
2025-01-14 03:20:05 -08:00
committed by Facebook GitHub Bot
parent 817cb17f78
commit d95909ea15
2 changed files with 28 additions and 27 deletions
@@ -9,9 +9,9 @@
*/
import {RNTesterThemeContext} from './RNTesterTheme';
import RNTesterTitle from './RNTesterTitle';
import {useContext} from 'react';
const RNTesterTitle = require('./RNTesterTitle');
const React = require('react');
const {SafeAreaView, ScrollView, StyleSheet, View} = require('react-native');
@@ -9,33 +9,34 @@
*/
import {RNTesterThemeContext} from './RNTesterTheme';
import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
const React = require('react');
const {StyleSheet, Text, View} = require('react-native');
type Props = $ReadOnly<{
title: string,
}>;
class RNTesterTitle extends React.Component<$FlowFixMeProps> {
render(): React.Node {
return (
<RNTesterThemeContext.Consumer>
{theme => {
return (
<View
style={[
styles.container,
{
borderColor: theme.SeparatorColor,
backgroundColor: theme.TertiaryGroupedBackgroundColor,
},
]}>
<Text style={[styles.text, {color: theme.LabelColor}]}>
{this.props.title}
</Text>
</View>
);
}}
</RNTesterThemeContext.Consumer>
);
}
function RNTesterTitle({title}: Props): React.Node {
return (
<RNTesterThemeContext.Consumer>
{theme => {
return (
<View
style={[
styles.container,
{
borderColor: theme.SeparatorColor,
backgroundColor: theme.TertiaryGroupedBackgroundColor,
},
]}>
<Text style={[styles.text, {color: theme.LabelColor}]}>
{title}
</Text>
</View>
);
}}
</RNTesterThemeContext.Consumer>
);
}
const styles = StyleSheet.create({
@@ -53,4 +54,4 @@ const styles = StyleSheet.create({
},
});
module.exports = RNTesterTitle;
export default RNTesterTitle;