diff --git a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js
index 9bc01fcd3af2..6cb4a94567d2 100644
--- a/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js
+++ b/packages/rn-tester/js/examples/PlatformColor/PlatformColorExample.js
@@ -14,11 +14,14 @@ import type {ColorValue} from 'react-native';
import RNTesterText from '../../components/RNTesterText';
import React from 'react';
import {
+ Appearance,
+ Button,
DynamicColorIOS,
Platform,
PlatformColor,
StyleSheet,
View,
+ useColorScheme,
} from 'react-native';
function PlatformColorsExample() {
@@ -315,6 +318,48 @@ function VariantColorsExample() {
);
}
+function ReactsToAppearanceChangesExample() {
+ const theme = useColorScheme();
+ const key = Platform.select({
+ android: theme ?? '',
+ default: undefined,
+ });
+
+ return (
+ // using a key here forces the component to unmount and remount
+ // which is necessary to trigger the appearance change
+
+
+
+ {Platform.select({
+ ios: "DynamicColorIOS({light: 'red', dark: 'blue'})",
+ android: "PlatformColor('?attr/colorAccent')",
+ default: 'Unexpected Platform.OS: ' + Platform.OS,
+ })}
+
+
+
+
+
+ );
+}
+
const styles = StyleSheet.create({
column: {flex: 1, flexDirection: 'column'},
row: {flex: 0.75, flexDirection: 'row'},
@@ -326,6 +371,7 @@ const styles = StyleSheet.create({
}),
},
colorCell: {flex: 0.25, alignItems: 'stretch'},
+ separator: {height: 8},
});
exports.title = 'PlatformColor';
@@ -358,4 +404,10 @@ exports.examples = [
return ;
},
},
+ {
+ title: 'Reacts to Appearance Changes',
+ render(): React.MixedElement {
+ return ;
+ },
+ },
] as Array;