Skip to content
Advertisement

React Native giving error that variable is not defined when it is

I have linked an external JS File using require(), it has even recognized it. When i will call a function from that external file it will indicate that the function been recognized but it will still give error that it Can’t find the variable (in my case is a function named text()). My App.js:

JavaScript

functions.js:

JavaScript

I want it to run the test() function when the Login Now! button has been pressed

Advertisement

Answer

You need to export your functions from your functions.js first. And then, you can import it into your app. The following should work.

functions.js

JavaScript

app.js

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement