I'm using clean project and I cannot use require in any part of my code, for example here in the Image:
<Image
style={styles.stretch}
source={require('./img/favicon.png')}
/>
or in any other part like here using the react-native-router-flux plugin, I want to overwrite the back button image but I cannot change it because 'require' is not defined.
<Scene backButtonImage={require('./custom_icon.png')} />
This is my package.json
{
"name": "CleanProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "15.4.2",
"react-native": "0.40.0",
"react-native-router-flux": "^3.37.0"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"eslint": "^3.12.0",
"eslint-plugin-react": "^6.8.0",
"jest": "18.1.0",
"react-test-renderer": "~15.4.0-rc.4"
},
"jest": {
"preset": "react-native"
}
}
Do you have any idea?
It's probably just a config issue with your Linter. It should build just fine. If you want to remove the error in your developer tool and are using ESLint, at the top of your file try adding:
/* global require */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With