Comments (17)
Hi @AidanWelch,
I tried upgrading to v10.6.7 today. It is still the same error with Expo SDK 46.
from google-translate-api.
Just an update. I upgraded my app to Expo SDK 49, and the issue persists. The error is exactly the same.
I noticed that you were using axios in v10.4.2, and changed to fetch after that. fetch is not a standard function in react native, and it requires to be imported import {fetch} from 'react-native
. Sorry that I didn't look into your codes until now. I accidentally discovered it while looking into all the dependencies that need to be upgraded for the Expo SDK upgrade.
from google-translate-api.
Hi, can you post the code?
from google-translate-api.
Hello @AidanWelch
Specific to my environment, I'm using Expo SDK46 android development build to run the codes. I found that I upgraded the package version accidentally, and downgrading it to v10.4.2 fixes it. It broke somewhere after v10.4.2. The latest version is broken as well.
await translate(trText, { to: lang})
.then((value) => trResult.push({ language: lang, text: value.text, fromLang: value.from.language.iso}))
.catch((error) => console.log('translation error :', error))
Thanks to look into it.
from google-translate-api.
Can you check if the Fetch API is exposed in your environment?
from google-translate-api.
Fetch is working fine in my environment. I also have the below error with v10.5.4.
Possible Unhandled Promise Rejection (id: 1):
TypeError: (0 , _googleTranslateApiX.default) is not a function
{arguments: ["Possible Unhandled Promise Rejection (id: 1):\nTypeError: (0 , _googleTranslateApiX.default) is not a function"], logger: console}
from google-translate-api.
Can you try instead of doing
const translate = require('google-translate-api-x');
// Or
import translate from 'google-translate-api-x';
Instead doing
import { translate } from 'google-translate-api-x';
// or
const { translate } = require('google-translate-api-x');
I wonder if it's an issue with handling the default exports in that enviroment
from google-translate-api.
I tried before I opened the issue, it was not working.
from google-translate-api.
@leons1767 Can you try installing this in your project and running in your babel config: https://babeljs.io/docs/babel-preset-env
That fixes the issue for me.
from google-translate-api.
Hi @AidanWelch
I installed babel-preset-env, but what do I need to add in my babel.config.js? My current babel config in below.
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
env: {
production: {
plugins: ['react-native-paper/babel'],
},
},
plugins: ['react-native-reanimated/plugin'],
};
};
from google-translate-api.
After testing I actually ran into other issues with babel-preset-env
so instead I started using @babel/plugin-proposal-private-methods
which after installing you can add to your config like so:
module.exports = function(api) {
api.cache(true);
return {
presets: ['babel-preset-expo'],
env: {
production: {
plugins: ['react-native-paper/babel'],
},
},
plugins: ['react-native-reanimated/plugin', ['@babel/plugin-proposal-private-methods', { loose: true }]],
};
};
from google-translate-api.
Thanks for your time to support. I tried @babel/plugin-proposal-private-methods, added the exact babel config, and it's still giving the same error.
TypeError: (0 , _googleTranslateApiX.default) is not a function
from google-translate-api.
Hmm, I think it might be an issue with certain JS features not being supported in your version of expo or babel-preset-expo
as it works perfectly fine with that config for me in expo 48.
from google-translate-api.
Unfortunately, I can't upgrade from Expo SDK46 to SDK48 yet, due to the dependency on RN0.71 in the SDK48. I guess I will have to do with v10.4.2 for now.
from google-translate-api.
Hmm, it may be possible to get it to work. You could also try adding @babel/plugin-proposal-object-rest-spread
like the last plugin. And if that doesn't work there might be other babel config changes you can make to support newer JS features
from google-translate-api.
Should no longer be required in v10.6.7
from google-translate-api.
That's really weird because I have a react native project where I didn't have to import fetch
but regardless, I'm glad you resolved it!
from google-translate-api.
Related Issues (20)
- Autocorrect not properly applied to translations from certain networks HOT 6
- Real-time translation HOT 2
- ReferenceError: fetch is not defined HOT 2
- TypeScript Error HOT 2
- requestOptions documentation outdated HOT 3
- It throws error "fetch is not defined" HOT 2
- Tests fail only because rate limited on single translate HOT 1
- google-translate-api-x gives below error HOT 3
- Improve `speak` testing
- Caught an error from batch translate HOT 8
- ERROR [TypeError: Cannot convert null value to object] HOT 2
- Issue with the speak functionality HOT 2
- Batch translation error HOT 4
- Can't run on React.js HOT 2
- Big translation slowed down HOT 11
- change speak speed HOT 2
- fetch is not defined after deployment HOT 2
- CORS policy error HOT 4
- Obtain translation synonyms HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from google-translate-api.