Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error when using connect (function of the react-redux library)

I have a component class that I am using react-redux to connect the redux store, but I am getting an error when I try to pass the component into the connect function.

_react.default.memo is not a function. (In '_react.default.memo(ConnectFunction), '_react.default.memo' is undefined)

wrapWithConnect C:\Users\SESA506797XmobileApp Gatherman\node modul es react-redux\lib\components connectAdvanced.js: 339:45

I enclose an image of the generated errerur

Here is the content of the class in which connect was called

FilmDetail

import React from 'react'
import { StyleSheet, View, ActivityIndicator, ScrollView, Text, Image } 
from 'react-native'
import { getFilmDetailFromApi, getImageFromApi } from '../API/TMDBApi'
import { connect } from 'react-redux'

class FilmDetail extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      film: undefined,
    }
  }
  componentDidMount() {
    getFilmDetailFromApi(this.props.navigation.state.params.idFilm).then(data => {
      this.setState({
        film:data,
        isLoading: false
      })
    })
  }

  _displayFilm(){
    const film = this.state.film
    if(film != undefined){
      return(
        <ScrollView style={styles.scrollView_container}>
          <Image
            style = {styles.image}
            source = {{uri: getImageFromApi(film.backdrop_path)}}
          />
          <Text style={styles.title_text}>{film.title}</Text>
          <Text style={styles.description_text}>{film.overview}</Text>
          <Text style={styles.default_text}>Note : {film.vote_average} / 10</Text>
        </ScrollView>
      )
    }
  }

  render() {
    return (
      <View style={styles.main_container}>
        {this._displayFilm()}
      </View>
    )
  }
}

const styles = StyleSheet.create({
  main_container: {
    flex: 1
  },
})

const mapStateToProps = (state) => {
  return state
}

export default connect(mapStateToProps)(FilmDetail)

This is my package.json

 {
      "main": "node_modules/expo/AppEntry.js",
      "scripts": {
        "start": "expo start",
        "android": "expo start --android",
        "ios": "expo start --ios",
        "eject": "expo eject"
      },
      "dependencies": {
        "expo": "^32.0.0",
        "numeral": "^2.0.6",
        "react": "16.5.0",
        "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
        "react-native-modal": "^9.0.0",
        "react-navigation": "^3.6.1",
        "react-redux": "^7.0.1",
        "redux": "^4.0.1"
      },
      "devDependencies": {
        "babel-preset-expo": "^5.0.0"
      },
      "private": true
    }
like image 373
Soutou Avatar asked Apr 09 '19 19:04

Soutou


2 Answers

Had a while ago what I think is the same problem as you. I updated to the latest React version with:

npm install react@latest

Then installed version 0.4.0 of the react schedule package with:

npm i [email protected] --save-dev

And downgraded react-redux with

npm i [email protected]

at least for the moment my problem is solved, hope it works with yours.

like image 151
Samuel Vera Avatar answered Oct 31 '22 13:10

Samuel Vera


If you're using expo, you have to downgrade your react-redux and clear expo cache.

npm i [email protected]

npm i

expo r -c
like image 37
Caio Kretzer Avatar answered Oct 31 '22 13:10

Caio Kretzer