Subhransu Mishra
Subhransu Mishra

Reputation: 3061

Unhandled JS Exception: Invariant Violation: Invalid hook call with React-Redux Connect #15822

I am new to react native and I am trying to implement Redux in my application. React native throwing error while using connect function from react-redux as follows.

export default connect()(MyComponent);

I checked all 3 options and I am not breaking any:

  1. You might have mismatching versions of React and the renderer (such as React DOM)
  2. You might be breaking the Rules of Hooks(Not sure)
  3. You might have more than one copy of React in the same app

Version of dependancies listed below:

"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-native": "0.57.7",
"react-native-elements": "^0.19.1",
"react-native-geocoding": "^0.3.0",
"react-native-gesture-handler": "^1.0.12",
"react-native-maps": "https://github.com/react-community/react-native-maps.git",
"react-native-modal": "^9.0.0",
"react-native-router-flux": "^4.0.6",
"react-native-size-matters": "^0.1.4",
"react-native-super-grid": "^3.0.4",
"react-native-vector-icons": "^4.6.0",
"react-navigation": "^3.0.9",
"react-redux": "^7.0.3",
"redux": "^4.0.1",
"redux-logger": "^3.0.6"

Error disappear when I remove connect(). But it prevents from implanting Redux

Is this a bug in React Native or I am doing something wrong here?

Upvotes: 1

Views: 678

Answers (1)

Sergii Shvager
Sergii Shvager

Reputation: 1256

Try to update react-native to 0.59.x.

Looks like react-redux switched to use React hooks internally. But react-native added React hooks support starting from version 0.59 (https://facebook.github.io/react-native/blog/2019/03/12/releasing-react-native-059).

Upvotes: 1

Related Questions