From 1cfd7ddd03df903c6b61d4d01ace11eabe5faad7 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Mon, 16 Oct 2023 08:20:55 -0700 Subject: [PATCH] Make sure onIntArrayChanged is invoked on RN Tester (#40940) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/40940 Currently the `onIntArrayChanged` event is invoked only once inside RN Tester. I'm changing the logic to make sure it fires whenever we click "Set Opacity" Changelog: [Internal] [Changed] - Make sure onIntArrayChanged is invoked on RN Tester Reviewed By: mdvacca, dmytrorykun Differential Revision: D50264765 fbshipit-source-id: 93a60fd1b657c3d8b8182cab6bb7cd4368ac9a42 --- .../rn-tester/NativeComponentExample/js/MyNativeView.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/rn-tester/NativeComponentExample/js/MyNativeView.js b/packages/rn-tester/NativeComponentExample/js/MyNativeView.js index c74c0f084e7648..fe32899209e87a 100644 --- a/packages/rn-tester/NativeComponentExample/js/MyNativeView.js +++ b/packages/rn-tester/NativeComponentExample/js/MyNativeView.js @@ -87,6 +87,7 @@ export default function MyNativeView(props: {}): React.Node { const ref = useRef | null>(null); const legacyRef = useRef | null>(null); const [opacity, setOpacity] = useState(1.0); + const [arrayValues, setArrayValues] = useState([1, 2, 3]); const [hsba, setHsba] = useState(new HSBA()); const [cornerRadiusIndex, setCornerRadiusIndex] = useState(0); const [legacyMeasure, setLegacyMeasure] = @@ -102,7 +103,7 @@ export default function MyNativeView(props: {}): React.Node { ref={ref} style={{flex: 1}} opacity={opacity} - values={[0, 1, 2, 3, 4]} + values={arrayValues} onIntArrayChanged={event => { console.log(event.nativeEvent.values); console.log(event.nativeEvent.boolValues); @@ -154,6 +155,11 @@ export default function MyNativeView(props: {}): React.Node { title="Set Opacity" onPress={() => { setOpacity(Math.random()); + setArrayValues([ + Math.floor(Math.random() * 100), + Math.floor(Math.random() * 100), + Math.floor(Math.random() * 100), + ]); }} />