useStableCallback causing troubles in New Architecture #2009
pavel-krasnov
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, I am developing a New Architecture app and trying to use this library. I noticed that when I use the
BottomSheetScrollViewcomponent, theonContentSizeChangecallback is not called. A short investigation led me to how this callback is passed to the underlying React NativeScrollViewcomponent. It is done using theuseStableCallbackhook, which is intended to not cause rerenders when the callback reference changes. Also I noticed the comment which was left two years after @gorhom had implemented the hook in this library saying that you probably don't need to useuseEffectto update the callback reference. This appers to be so true - looks like by the time theuseEffectis called, the New Architecture version of theonContentSizeChangehas been already called and thus the callback, which was undefined in the time of calling, couldn't be called. I replaceduseEffectwith simply settings the ref value in the hook body and everything started to work.So I would like to ask you for an opinion if such a change can be introduced to the library any time soon.
Beta Was this translation helpful? Give feedback.
All reactions