-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Warning - 'getNode() deprecation fix' #673
Conversation
+1 |
@dilinade Thanks for the PR! I'd be happy to merge this, but I fear this might break things for users who haven't migrated to the latest version of React Native... Think you can make it backward-compatible? |
@bd-arc Hi, I have made some changes. Please review :) |
@dilinade I think it's not efficient to check the version of React Native every time in |
@dilinade Couple of notes:
Putting it all together, here's my suggestion (untested). What do you guys think? constructor (props) {
super(props);
// Everything else...
this._shouldUseGetNode = this._useGetNode();
}
_useGetNode () {
const package = require('../../../react-native/package.json');
const version = package && package.version;
if (!version) {
return true;
}
const versionSplit = version.split('.');
if (!versionSplit || !versionSplit.length) {
return true;
}
const versionCode = versionSplit[0] * 1000000 + versionSplit[1] * 10000 + versionSplit[2] * 100;
return versionCode < 620000; // RN 0.62
}
_getWrappedRef () {
// https://github.com/facebook/react-native/issues/10635
// https://stackoverflow.com/a/48786374/8412141
return this._shouldUseGetNode ?
this._carouselRef && this._carouselRef.getNode && this._carouselRef.getNode() :
this._carouselRef;
} |
@bd-arc Got it and Cool :) |
i'm using this version 'react-native-snap-carousel@4.0.0-beta.2' but still got the error. Is this the same with this release? |
@dilinade Did you made the suggested changes? Is this PR ready to go forward? |
Unfortunately the following basically breaks everything on Snack because it is This is a quite a big issue and I'm scratching my head to find a way to make it work. Requiring the package conditionally would be the obvious way to go, but unfortunately this is not supported by the React Native packager (see this thread for example). Also tried with a If anyone has an idea to address that, please let everyone know! |
Could we check if
|
@bd-arc I guess Expo is using this to load the files: expo-asset I'm not sure if we use this, that's gonna support RN too or not. Which I think it will because expo is supporting most of React Native API's these days. Also take a look at this too: here |
+1 |
Well, this definitely seems to solve the problem on |
Just included @r0b0t3d's suggestion in the v4 beta branch and published version Note that I didn't test it on RN pre- If someone wants to jump in... |
Unfortunately, the suggestion doesn't work on versions < 0.62. Back to square one... |
Fixed in version |
Platforms affected
Android & iOS
What does this PR do?
Fixes #672
What testing has been done on this change?
Tested features checklist
enableMomentum
)vertical
)activeSlideAlignment
)autoplay
)loop
)ScrollView
/FlatList
carousels (propuseScrollView
)ParallaxImage
componentPagination
component