Skip to content

Commit

Permalink
Migrate rn-tester/js/components/RNTesterTitle.js to function componen…
Browse files Browse the repository at this point in the history
…ts (#48649)

Summary:

As per title.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D68099051
  • Loading branch information
fabriziocucci authored and facebook-github-bot committed Jan 13, 2025
1 parent 31df8a0 commit 200497f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 27 deletions.
2 changes: 1 addition & 1 deletion packages/rn-tester/js/components/RNTesterPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down
53 changes: 27 additions & 26 deletions packages/rn-tester/js/components/RNTesterTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -53,4 +54,4 @@ const styles = StyleSheet.create({
},
});

module.exports = RNTesterTitle;
export default RNTesterTitle;

0 comments on commit 200497f

Please sign in to comment.