Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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:

  • expo-cli: 4.0.17
  • expo-sdk: 40.0.1 (react-native 0.63.3)
  • react: 16.13.1
  • react-dom: 16.13.1

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:

  • reinstall node_modules, clear npm cache, delete watchers.
  • use React.useState instead of useState.
  • check for help on expo forums.

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

like image 451
Guille Acosta Avatar asked Nov 01 '25 18:11

Guille Acosta


1 Answers

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.

like image 158
Guille Acosta Avatar answered Nov 04 '25 09:11

Guille Acosta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!