[ios] (0,w.useState) is not a function. error on archive(release) version
See original GitHub issuePlease provide all the information requested. Issues that do not follow this format are likely to stall.
Description
The error code below is from XCode. This error happenes only on archived(release) version of the app. In debug mode, it’s all good.
*** Terminating app due to uncaught exception 'RCTFatalException: Unhandled JS Exception: TypeError: (0,w.useState) is not a function. (In '(0,w.useState)(!1)', '(0,w.useState)' is undefined)
This error is located at:
in j
in RCTView
in View
in f
in n
in Unknown
in Unknown
in Unknown
in Unknown
in RCTView
in View
in H
in RCTView
in View
in RCTView
in View
in Unknown
in RCTView
in View
in f
in Unknown
in D
in Unknown
in te
in Unknown
in Unknown
in Unknown
in Unknown
in RCTView
in View
in RCTView
in View
in RCTView
in View
in ForwardRef
in RCTView
in View
in k
in ForwardRef
in PanGestureHandler
in Unknown
in RCTView
in View
in k
in ForwardRef
in RCTView
in View
in G
in Unknown
in RCTView
in View
in Unknown
in RCTView
in View
in Unknown
in O
in h
in Unknown
in RCTView
in View
in G
in Unknown
in re
in Unknown
in ForwardRef
in Unknown
in ForwardRef
in RNCSafeAreaProvider
in Unknown
in Unknown
in _
in RCTView
in View
in Unknown
in y
in Root
in RCTView
in View
in C', reason: 'Unhandled JS Exception: TypeError: (0,w.useState) is not a function. (In '(0,w.useState)(!1)', '(0,w.useState)' is undefined)
This error is located at:
in j
in RCTVie..., stack:
j@1359:1779
fr@98:38814
Ci@98:80362
Cl@98:74733
Rl@98:74658
Pl@98:74425
Tl@98:71558
Tl@(null):(null)
<unknown>@98:23572
<unknown>@203:3882
an@98:23519
ln@98:23454
xe@98:89263
Se@98:12419
Re@98:12808
receiveEvent@98:13217
value@27:3350
<unknown>@27:747
value@27:2610
value@27:719
value@(null):(null)
'
React Native version:
Run react-native info
in your terminal and copy the results here.
System:
OS: macOS 11.1
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 45.89 MB / 8.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 10.15.3 - /usr/local/bin/node
Yarn: Not Found
npm: 6.4.1 - /usr/local/bin/npm
Watchman: Not Found
Managers:
CocoaPods: 1.9.3 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: iOS 14.3, DriverKit 20.2, macOS 11.1, tvOS 14.3, watchOS 7.2
Android SDK:
API Levels: 26, 28, 29
Build Tools: 26.0.2, 28.0.3, 29.0.0, 29.0.2, 29.0.3
System Images: android-28 | Google Play Intel x86 Atom
Android NDK: Not Found
IDEs:
Android Studio: 4.0 AI-193.6911.18.40.6626763
Xcode: 12.3/12C33 - /usr/bin/xcodebuild
Languages:
Java: 1.8.0_201 - /usr/bin/javac
Python: 2.7.16 - /usr/bin/python
npmPackages:
@react-native-community/cli: Not Found
react: 16.13.1 => 16.13.1
react-native: 0.63.4 => 0.63.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps To Reproduce
Provide a detailed list of steps that reproduce the issue.
- Build an app in release mode or archive the app on XCode
- The error above happens
Expected Results
Describe what you expected to happen. It runs without any errors just like the app of debug mode.
Snack, code example, screenshot, or link to a repository:
Please provide a Snack (https://snack.expo.io/), a link to a repository on GitHub, or provide a minimal code example that reproduces the problem. You may provide a screenshot of the application if you think it is relevant to your bug report. Here are some tips for providing a minimal example: https://stackoverflow.com/help/mcve
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
Hi @giftset, I had a similar problem. You probably used auto-import and imported useState from the wrong path.
You have to use
import { useState } from "react";
instead of
import { useState } from "react/cjs/react.development";
Thank you so mush, I wasted a lot time on this problem, your comment helped me.