Page MenuHomePhabricator

[native] Migrate Tooltip component to Reanimated v2 API
ClosedPublic

Authored by angelika on Wed, Dec 11, 8:26 AM.
Tags
None
Referenced Files
F3507246: D14117.id46336.diff
Fri, Dec 20, 7:58 PM
F3506255: D14117.id46474.diff
Fri, Dec 20, 3:54 PM
F3504817: D14117.id46335.diff
Fri, Dec 20, 10:36 AM
F3504742: D14117.id46411.diff
Fri, Dec 20, 10:27 AM
F3504704: D14117.id46510.diff
Fri, Dec 20, 10:09 AM
Unknown Object (File)
Fri, Dec 20, 2:49 AM
Unknown Object (File)
Thu, Dec 19, 8:12 PM
Unknown Object (File)
Thu, Dec 19, 4:11 AM
Subscribers
None

Details

Summary

This diff migrates now functional Tooltip component to Reanimated V2 api. This includes:

  • using useAnimatedStyle instead of useMemo for animated styles
  • moving reanimated nodes and their interpolations into useAnimatedStyle worklet
  • migrating tooltipHorizontalOffset to shared value
  • using positionV2 instead of position
  • I passed opacityStyle and styles.backdrop as separate styles because you can’t merge those styles like they were originally merged, this shouldn’t have any impact though

Also I calculate getTooltipLocation(), getMargin() and getTooltipHeight() outside of a worklet. The reason is that I’d need to make them into worklets and they’re calling functions that I’d need to make into worklets too and those functions are calling some Map or Set operations that are not worklets so it’s a mess. And worklets are supposed to be small functions after all. The results of those functions are in useAnimatedStyle dependencies and they shouldn’t change much so it should be ok

Depends on D14113

Test Plan

Open up tooltips and verify they're animated correctly

Diff Detail

Repository
rCOMM Comm
Lint
No Lint Coverage
Unit
No Test Coverage

Event Timeline

angelika held this revision as a draft.
ashoat added inline comments.
native/tooltip/tooltip.react.js
505 ↗(On Diff #46335)

We usually wrap any prop like this (getting recreated on each render) with React.useMemo

This revision is now accepted and ready to land.Wed, Dec 11, 7:49 PM

Rebase and address feedback