Guille Acosta
Guille Acosta

Reputation: 2222

Expo App works fine on development mode but crashes on productions

I'm currently developing a simple orders app which works ok on development, but if I install the apk from build or run the app on production mode through Expo Client I get this error:

TypeError: (0,f.useState) is not a function. (In '(0,f.useState)(!0)', '(0,f.useState)' is undefined)

This error is located at:
    in C
    in B
    in RCTView
    in View
    in RCTView
    in View
    in RCTScrollView
    in y
    in ScrollView
    in w
    in P
    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 H
    in Unknown
    in RCTView
    in View
    in Unknown
    in RCTView
    in View
    in Unknown
    in w
    in b
    in RNCSafeAreaProvider
    in Unknown
    in Unknown
    in RCTView
    in View
    in x
    in Unknown
    in Unknown
    in O
    in P
    in RCTView
    in View
    in RCTView
    in View
    in O
    in RCTView
    in View
    in f
    in RCTView
    in View
    in AnimatedComponent(View)
    in RCTView
    in View
    in AnimatedComponent(View)
    in PanGestureHandler
    in le
    in L
    in O
    in P
    in R
    in O
    in O
    in l
    in c
    in Unknown
    in Unknown
    in RCTView
    in View
    in RCTView
    in View
    in C

My current config is:

This error doesn't happen at startup but when I reach a particular page. Things I tried so far after reading a lot of QA about TypeError: (0,f.useState) is not a function:

Does anybody know how to fix this issue? Or what can I try to make it work? Regards!

Upvotes: 4

Views: 7111

Answers (2)

Zohaib Asghar
Zohaib Asghar

Reputation: 1

Just run the command

npm i react-native-screens

  • advice: try to use strict typescript for in-depth warnings and errors

Upvotes: -1

Guille Acosta
Guille Acosta

Reputation: 2222

I run the app in prod mode without --minify arg (expo start --no-dev) and I was able to fix this issue.

Debugging I found autocomplete imported useState from another instance of React which caused this issue.

Hope this helps anybody with this or similar issues.

Upvotes: 7

Related Questions