Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion packages/rn-tester/NativeComponentExample/js/MyNativeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ function getTextFor(measureStruct: MeasureStruct): string {
measureStruct.height,
)}`;
}
const opacityDecrementCounter = 0.2;

function computeNextOpacity(opacity: number): number {
if (parseFloat(opacity.toFixed(1)) > 0.0) {
return opacity - opacityDecrementCounter;
}
return 1.0;
}

// This is an example component that migrates to use the new architecture.
export default function MyNativeView(props: {}): React.Node {
Expand Down Expand Up @@ -201,7 +209,7 @@ export default function MyNativeView(props: {}): React.Node {
<Button
title="Set Opacity"
onPress={() => {
setOpacity(Math.random());
setOpacity(computeNextOpacity(opacity));
setArrayValues([
Math.floor(Math.random() * 100),
Math.floor(Math.random() * 100),
Expand Down