HomePhabricator
Diffusion Comm 51fd3ffa71d0

[native] Introduce positionsV2 values in OverlayNavigator

Description

[native] Introduce positionsV2 values in OverlayNavigator

Summary:
This diff introduces a new positionV2 variable that is a SharedValue from Reanimated V2 API. The old position variable stays the same and is marked as depracated. Later on when we replace all usages of position with positionV2 we can rename it back to position. Made a linear issue here: https://linear.app/comm/issue/ENG-10006/rename-postitionv2-variables-in-overlaynavigator-to-position

Why have I used makeMutable: normally I'd have used useSharedValue but it's a hook. Rules of hooks say that we can't change or add hook calls during a lifetime of a component. But we want a shared value for every screen and screens are added dynamically. So I see two solutions here:

  • assume a max amount of screens x and make x shared values at the beginning then assign them when needed
  • use makeMutable

The first solution is a bit cumbersome so I went with the second solution. makeMutable is a bit of an internal function but it's documented in reanimated v3: https://docs.swmansion.com/react-native-reanimated/docs/advanced/makeMutable and it's available also in reanimated v2. And all useSharedValue does is it uses makeMutable and cleans up after it's not needed. I added clean up code according to reanimated docs.

Depends on D14099

Test Plan: Flow and run the app

Reviewers: ashoat, tomek

Reviewed By: ashoat

Differential Revision: https://phab.comm.dev/D14102

Details

Provenance
angelikaAuthored on Thu, Nov 28, 2:31 PM
Reviewer
ashoat
Differential Revision
D14102: [native] Introduce positionsV2 values in OverlayNavigator
Parents
rCOMM78c5b78ee76d: [native] Add reanimated makeMutable function type
Branches
Unknown
Tags
Unknown