kirillzyusko / react-native-keyboard-controller

Keyboard manager which works in identical way on both iOS and Android
https://kirillzyusko.github.io/react-native-keyboard-controller/
MIT License
1.54k stars 61 forks source link

fix: do not use `target` property from `onLayout` #382

Closed kirillzyusko closed 5 months ago

kirillzyusko commented 5 months ago

📜 Description

Do not use target property from onLayout.

💡 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 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

🤔 How Has This Been Tested?

Tested paper & Fabric on iOS 17.2 (iPhone 15 simulator).

📝 Checklist

github-actions[bot] commented 5 months ago

📊 Package size report

Current size Target Size Difference
135401 bytes 134628 bytes 773 bytes 📈