facebookarchive / react-native-custom-components

Breaking apart the Libraries/CustomComponents part of the React Native repo
Other
70 stars 158 forks source link

React Lifecycle functions are not called in their respective order #28

Closed jnrepo closed 6 years ago

jnrepo commented 6 years ago

I'm running into a weird issue where componentWillUnmount and render react-lifecycle function will get called before componentWillMount and cause a lot of undefined errors. Interestingly enough this only happens on release mode for iOS.

TypeError: undefined is not an object (evaluating 'this._subscribableSubscriptions.forEach')

This error is located at:
    in Navigator
    in RCTView
    in t
    in Connect(t)
    in t
    in n
    in t
    in RCTView
    in RCTView
    in t

Suddenly started happening, I'm not quite sure why.

react-native: 0.51.0 react-native-custom-components: latest-commit (not published yet)

shan-ge commented 6 years ago

I got similar case, happened on release mode for iOS:

This error is located at: in RCTView in a in a in RCTView in RCTView in RCTView in Navigator in RCTView in t in RCTView in RCTView in t 2018-01-10 09:46:37.743753+0800 EvaApp[7627:820330] Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

This error is located at: in RCTView in a in a in RCTView in RCTView in RCTView in Navigator in RCTView in t in RCTView in RCTView in t 2018-01-10 09:46:37.748 [error][tid:com.facebook.react.JavaScript] { [Invariant Violation: Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

jnrepo commented 6 years ago

@ruinangel

after some digging this was the cause https://github.com/facebook/react-native/issues/17348#issuecomment-356350102

The issue was with one of the newer version of uglify-es. If you upgrade to the latest React Native the dependency was updated so it should work, but for whatever reason you want to stay on your version you can do npm install -save uglify-es@3.2.2 which will pin the working dependency into your module.

Make sure the dependency is uglify-es: "3.2.2" and not uglify-es: "^3.2.2" in your package.json.

Since this isn't an issue of this component, going to close this one out.