Open Ruta-Radiya opened 4 years ago
RESOLVED, after spending hours !!! Changed: module.exports = Swiper line from react-native-swiper/index.js to export default Swiper;
RESOLVED, after spending hours !!! Changed: module.exports = Swiper line from react-native-swiper/index.js to export default Swiper;
Thanks! Works for me.
Have the same problem, it would be nice to be es6 syntax by default or having something like
if( module ) { module.export.. } else { export default .. }
Thanks for the awesome work ;)
The solution that worked for me is import Swiper from 'react-native-swiper/src'
.
The code for index.js
simply exports the Swiper in src.
import Swiper from './src/'
/**
* Resolve ES6 and CommonJS compatibility issues
* 1. CommonJS code
* const Swiper = require('react-native-swiper');
* 2. ES6 code
* import Swiper from 'react-native-swiper';
*/
module.exports = Swiper;
module.exports.default = Swiper;
RESOLVED, after spending hours !!! Changed: module.exports = Swiper line from react-native-swiper/index.js to export default Swiper;
Could not understand, can you please explain it again ?
The solution that worked for me is
import Swiper from 'react-native-swiper/src'
.The code for
index.js
simply exports the Swiper in src.import Swiper from './src/' /** * Resolve ES6 and CommonJS compatibility issues * 1. CommonJS code * const Swiper = require('react-native-swiper'); * 2. ES6 code * import Swiper from 'react-native-swiper'; */ module.exports = Swiper; module.exports.default = Swiper;
This works for me, Thank You derdoses.
Which OS ?
Windows
Version
Which versions are you using:
Expected behaviour
Basic swipe functionaly code works
Actual behaviour
Cannot assign to read only property 'exports' of object - error AvatarSelectionScreen_BasicSwipe.txt
How to reproduce it>
To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.
Steps to reproduce
import Swiper from 'react-native-swiper'
const styles = StyleSheet.create({ wrapper: {}, slide1: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#9DD6EB' }, slide2: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#97CAE5' }, slide3: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: '#92BBD9' }, text: { color: '#fff', fontSize: 30, fontWeight: 'bold' } })
export default class SwiperComponent extends Component { render() { return (
} }
AppRegistry.registerComponent('myproject', () => SwiperComponent) 3.Modified as attached in AvatarSelectionScreen_BasicSwipte.txt