In continuation of https://github.com/facebook/react-native/pull/42785 it seems like target property is not documented and thus can be removed at any point of time so it's simply not reliable to use it since the code can be easily broken in newest RN versions.
So in this PR I started to use findNodeHandle and pass a ref to get a view target. Initially I thought that it'll throw a warning in strict mode, but it looks like this method will throw a warning only if findNodeHandle(component) statement is used. And since I'm passing a ref - it's safe to use such code.
Also I'm still getting target property in onLayout. Maybe more optimized version would be to derive a target property in onRef handler, but it's further improvements/optimizations (we need to make changes gradually).
📢 Changelog
JS
use findNodeHandle in onLayout instead of target property from event;
🤔 How Has This Been Tested?
Tested paper & Fabric on iOS 17.2 (iPhone 15 simulator).
📝 Checklist
[x] CI successfully passed
[x] I added new mocks and corresponding unit-tests if library API was changed
📜 Description
Do not use
target
property fromonLayout
.💡 Motivation and Context
In continuation of https://github.com/facebook/react-native/pull/42785 it seems like
target
property is not documented and thus can be removed at any point of time so it's simply not reliable to use it since the code can be easily broken in newest RN versions.So in this PR I started to use
findNodeHandle
and pass aref
to get a view target. Initially I thought that it'll throw a warning in strict mode, but it looks like this method will throw a warning only iffindNodeHandle(component)
statement is used. And since I'm passing aref
- it's safe to use such code.Also I'm still getting
target
property inonLayout
. Maybe more optimized version would be to derive atarget
property inonRef
handler, but it's further improvements/optimizations (we need to make changes gradually).📢 Changelog
JS
findNodeHandle
inonLayout
instead oftarget
property from event;🤔 How Has This Been Tested?
Tested paper & Fabric on iOS 17.2 (iPhone 15 simulator).
📝 Checklist