james murphy
james murphy

Reputation: 1785

React native Redux - object is not a constructor (evaluating 'new ctor(props context)')

This is a very simple page that is trying to use Redux....see code below.

However Im getting the error object is not a constructor (evaluating 'new ctor(props context)')

import React, {Component} from 'react';
import {Text, View} from 'react-native';
import {connect} from 'react-redux';

const mapStateToProps = state => ({
  userId: state.auth.userId,
});

class Message extends Component {
  render() {
    return (
      <View>
        <Text>Text here</Text>
      </View>
    );
  }
}

export default connect(
  mapStateToProps,
  null,
)(Message);

Upvotes: 20

Views: 15530

Answers (3)

Pandu Rijal Pasa
Pandu Rijal Pasa

Reputation: 91

for the yarn user, I tried this, totally works

yarn cache clean

Upvotes: 3

Ankur Singh
Ankur Singh

Reputation: 128

Restarting the builder works..

Upvotes: 1

Eduardo Henrique
Eduardo Henrique

Reputation: 682

Reset cache work for me:

react-native start --reset-cache

Other solution is use createSwitchNavigator instead createStackNavigator, in your navigator container.

Upvotes: 43

Related Questions