country-state-city icon indicating copy to clipboard operation
country-state-city copied to clipboard

Usage with react native

Open maharjanaman opened this issue 5 years ago • 24 comments

When I use this library with react native projects, I'm getting this Maximum call stack size exceeded error. So is this not usable for react native?

maharjanaman avatar Jun 20 '19 18:06 maharjanaman

Someone forked this repo to fix this issue Please check, https://github.com/wkoutre/country-state-city

harpreetkhalsagtbit avatar Jul 09 '19 13:07 harpreetkhalsagtbit

dynamic import state and cities could be a solution for this. TBD: Future Release

harpreetkhalsagtbit avatar Sep 07 '19 12:09 harpreetkhalsagtbit

I have setup react-native(Latest) in Ubuntu 18.04 and tested with Andoird emulator, working fine. Would you please let me know about your environment and react-native version

harpreetkhalsagtbit avatar Sep 20 '19 13:09 harpreetkhalsagtbit

It doesn't in iOS simulator.

maharjanaman avatar Sep 20 '19 14:09 maharjanaman

Hi @maharjanaman I have also tested it with the iOS simulator with the latest - react-native version and it works fine. Maybe with the older version of react-native, it is failing.

So, I have added dynamic-import functionality and tested again with the iOS simulator. I have published my latest code as a beta version for this package.

Would you please also help me test this because I can't reproduce the error?

  1. First, check the original - country-state-city package.
  2. Then, if it still fails use, npm i country-state-city@beta
  3. test your code.

Thanks

harpreetkhalsagtbit avatar Sep 21 '19 14:09 harpreetkhalsagtbit

Hello, thanks for great contributions. Since, I was in hurry with releasing the app, I'd to find alternative approach for my app and hence couldn't test the beta version. If you think its working, you can close this issue. P.S. Thanks for the support.

maharjanaman avatar Oct 04 '19 03:10 maharjanaman

Actually, the original version is also working for me. So, I am not sure what actually was wrong. Still, I tried to fix it in this beta version. In that case, I will remain open this P.R until someone else faces a similar issue and then I will let him use this beta version and then proceed further with this.

Thanks for replying.

harpreetkhalsagtbit avatar Oct 04 '19 05:10 harpreetkhalsagtbit

Not working for me tried it with react 0.6.3 and getting the following error when running expo start --ios

- node_modules/react-native/Libraries/LogBox/LogBox.js:148:8 in registerError
- node_modules/react-native/Libraries/LogBox/LogBox.js:59:8 in errorImpl
- node_modules/react-native/Libraries/LogBox/LogBox.js:33:4 in console.error
- node_modules/expo/build/environment/react-native-logs.fx.js:27:4 in error
- node_modules/react-native/Libraries/Core/ExceptionsManager.js:104:6 in reportException
- node_modules/react-native/Libraries/Core/ExceptionsManager.js:171:19 in handleException
- node_modules/react-native/Libraries/Core/setUpErrorHandling.js:24:6 in handleError
- node_modules/expo-error-recovery/build/ErrorRecovery.fx.js:9:32 in ErrorUtils.setGlobalHandler$argument_0
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:293:29 in invoke
- node_modules/regenerator-runtime/runtime.js:63:36 in tryCatch
- node_modules/regenerator-runtime/runtime.js:154:27 in invoke
- node_modules/regenerator-runtime/runtime.js:164:18 in PromiseImpl.resolve.then$argument_0
- node_modules/react-native/node_modules/promise/setimmediate/core.js:37:13 in tryCallOne
- node_modules/react-native/node_modules/promise/setimmediate/core.js:123:24 in setImmediate$argument_0
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:130:14 in _callTimer
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:181:14 in _callImmediatesPass
- node_modules/react-native/Libraries/Core/Timers/JSTimers.js:441:30 in callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:387:6 in __callImmediates
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:135:6 in __guard$argument_0
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:364:10 in __guard
- node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:134:4 in flushedQueue
* [native code]:null in flushedQueue
* [native code]:null in invokeCallbackAndReturnFlushedQueue```

happens when trying to import the library like so

import csc from 'country-state-city'

hajjboy95 avatar Jan 26 '21 13:01 hajjboy95

I am getting this error when try to import csc from 'country-state-city' in react-native project.

ERROR RangeError: Maximum call stack size exceeded.

AlvaroBrasilia avatar Mar 03 '21 13:03 AlvaroBrasilia

This error is happens for react-native

hongzhou85 avatar Apr 17 '21 14:04 hongzhou85

With React Native 0.63.4 and version 2.0.0 of country-state-city it throws the error ERROR RangeError: The maximum size of the call stack was exceeded. As well as in the iOS and Android emulator, and in the physical Android device.

However if I run debug mode, I can work normally Android and iOS emulator, but the physical Android device cannot.

dannydanzka avatar Apr 22 '21 23:04 dannydanzka

@harpreetkhalsagtbit I am still getting this error ERROR RangeError: Maximum call stack size exceeded. ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[7], "country-state-city").Country') These are my versions. "country-state-city": "^3.0.1", "react": "17.0.1", "react-native": "0.64.2",

Fiyaz6772 avatar Jul 15 '21 10:07 Fiyaz6772

Error: Requiring module "node_modules/country-state-city/dist/index.js", which threw an exception: RangeError: Maximum call stack size exceeded.

Any solution?

amk-cb avatar Aug 14 '21 10:08 amk-cb

Actually, the original version is also working for me. So, I am not sure what actually was wrong. Still, I tried to fix it in this beta version. In that case, I will remain open this P.R until someone else faces a similar issue and then I will let him use this beta version and then proceed further with this.

Thanks for replying.

It is working fine in simulators but in real device it is throwing error.

amk-cb avatar Aug 14 '21 10:08 amk-cb

With React Native 0.63.4 and version 2.0.0 of country-state-city it throws the error ERROR RangeError: The maximum size of the call stack was exceeded. As well as in the iOS and Android emulator, and in the physical Android device.

However if I run debug mode, I can work normally Android and iOS emulator, but the physical Android device cannot.

I am facing a same issue with React-native 0.60.5 and country-state-city version 2.2.0. If I connect to debugger, app works just fine in iOS simulator, but with a real device or as soon as I stopped a debugger, its throwing an error.

tried the npm i country-state-city@beta too, I am still facing a same issue.

bmohankumar avatar Oct 07 '21 17:10 bmohankumar

I am still getting this error ERROR RangeError: Maximum call stack size exceeded. ERROR TypeError: undefined is not an object (evaluating '_$$_REQUIRE(_dependencyMap[7], "country-state-city").Country') These are my versions. "country-state-city": "^3.0.1", "react": "17.0.1", "react-native": "0.64.2",

Fiyaz6772 avatar Oct 11 '21 15:10 Fiyaz6772

I'm also getting this error "RangeError: Maximum call stack size exceeded." And "Error: Requiring module "node_modules\country-state-city\dist\index.js", which threw an exception: RangeError: Maximum call stack size exceeded."

I don't know what's happening.

JosiasBatista avatar Dec 30 '21 03:12 JosiasBatista

While im using this package , RangeError: Maximum call stack size exceeded I can't able to use my emulator also

KrishnanRoobanraj avatar Feb 17 '22 11:02 KrishnanRoobanraj

Still nothing on this?

adrienclay36 avatar Apr 16 '22 12:04 adrienclay36

I'm getting the same error. Anyone found a fix? And what are you using as it's working fine in React Native

bharat2913 avatar Sep 02 '22 12:09 bharat2913

I had the same issue with react native.

I changed the export default {} from the js files to just export {} and it worked.

Darmolar avatar Sep 08 '22 19:09 Darmolar

@Darmolar can you please explain in which file?

anuragipankaj avatar Sep 09 '22 11:09 anuragipankaj

Screenshot 2022-09-09 at 14 44 34

remove the default from that export part.

Please note that the cities might crash your application because the file has too much data. I suggest the creator uploads the cities into a database and queries from the database instead of using the filter.

Hope this helps @anuragipankaj

Darmolar avatar Sep 09 '22 13:09 Darmolar