Skip to content

Commit

Permalink
Make sure onIntArrayChanged is invoked on RN Tester (#40940)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
cortinico authored and facebook-github-bot committed Oct 16, 2023
1 parent e643a53 commit 071f610
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/rn-tester/NativeComponentExample/js/MyNativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default function MyNativeView(props: {}): React.Node {
const ref = useRef<React.ElementRef<MyNativeViewType> | null>(null);
const legacyRef = useRef<React.ElementRef<MyLegacyViewType> | null>(null);
const [opacity, setOpacity] = useState(1.0);
const [arrayValues, setArrayValues] = useState([1, 2, 3]);
const [hsba, setHsba] = useState<HSBA>(new HSBA());
const [cornerRadiusIndex, setCornerRadiusIndex] = useState<number>(0);
const [legacyMeasure, setLegacyMeasure] =
Expand All @@ -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);
Expand Down Expand Up @@ -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),
]);
}}
/>
<Button
Expand Down

0 comments on commit 071f610

Please sign in to comment.