gpt4 book ai didi

react-native - 使用连接时出错(react-redux 库的功能)

转载 作者:行者123 更新时间:2023-12-04 23:36:00 24 4
gpt4 key购买 nike

我有一个组件类,我使用 react-redux 来连接 redux 存储,但是当我尝试将组件传递到 connect 函数时出现错误。

_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

这是调用connect的类的内容

影片详情
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)

这是我的 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
}

最佳答案

前段时间我认为和你有同样的问题。我更新到最新的 React 版本:

npm install react@latest

然后安装了 0.4.0 版的 react schedule 包:
npm i schedule@0.4.0 --save-dev

并降级 react-redux
npm i react-redux@6.0.1

至少目前我的问题已经解决,希望它适用于你的问题。

关于react-native - 使用连接时出错(react-redux 库的功能),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55599755/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com