Mac Os
Which versions are you using:
react : 16.8.3
react-native : 0.59.1
react-native-swiper : ^1.5.14
Getting below warning -
Warning: ViewPagerAndroid has been extracted from react-native core and will be removed in a future release. It can now be installed and imported from '@react-native-community/viewpager' instead of 'react-native'. See https://github.com/react-native-community/react-native-viewpager
Run the application using react-native run-android
Can confirm having the same issue on clean and fresh project.
我也出现了同样的问题
So, what can we do now?
@afilp
Of course, you have chosen:
1) https://github.com/leecade/react-native-swiper/issues/713#issuecomment-476687466
2) Use another more contributable project
3) Don't use this module and upstar it
我也出现了同样的问题
怎么解决的
If you don't want the warning in your debugger's console log.
Will this problem be corrected in the next release?
no, not a single hint that this module will be developed in the near future
I have replaced this with a stable and good slider - https://github.com/Jacse/react-native-app-intro-slider
Its having similar features
If you don't want the warning in your debugger's console log.
- Install https://github.com/react-native-community/react-native-viewpager with yarn as mentionned in the Readme
- link library as mentionned in the doc
- go to .node_modulesreact-native-swipersrcindex.js and change the ViewPagerAndroid component with "ViewPager" (don't forget to import it with : import ViewPager from "@react-native-community/viewpager";)
4 It works for me.
Hope it helps.
This worked for me. The only downside is that you have redo the process in case of fresh npm install.
Thanks @grean. I hacked together a little postinstall script so this doesn't have to be done after every package install (@Rutheniceye92):
const fs = require('fs');
const path = require('path');
const moduleDir = path.resolve('./node_modules');
const swiperPath = path.join(moduleDir, 'react-native-swiper', 'src', 'index.js');
// Patch react-native-swiper for Android according to https://github.com/leecade/react-native-swiper/issues/951#issuecomment-493684332
if (fs.existsSync(path.join(moduleDir, '@react-native-community', 'viewpager', 'package.json'))) {
const swiperSource = fs.readFileSync(swiperPath).toString();
if (!swiperSource.match('@react-native-community/viewpager')) {
fs.writeFileSync(
swiperPath,
swiperSource
.replace(
"} from 'react-native'",
"} from 'react-native'\nimport ViewPager from '@react-native-community/viewpager'",
)
.replace('ViewPagerAndroid,\n ', '')
.replace(/ViewPagerAndroid/g, 'ViewPager'),
);
console.log('react-native-swiper patched using @react-native-community/viewpager');
} else console.log('react-native-swiper already contains @react-native-community/viewpager');
} else console.log('Please install @react-native-community/viewpager first');
Simply put this in a new JavaScript file (if you don't already have a postinstall script), and add this using node ./postinstall.js to the package.json in the scripts.postinstall section.
Thanks a lot @mfkrause ... your postinstall script was tremendously helpful.
RN V- >60
React-native-swiper 1.5.14
GO TO inside node module React-native-swiper
open src => index.js
then find ViewPagerAndroid and replace it by ScrollView {from 'react-native}
it will be work... good luck
Most helpful comment
If you don't want the warning in your debugger's console log.
4 It works for me.
Hope it helps.