Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript typeError:(0,_reactRedux.connect)不是函数_Javascript_React Native_Redux - Fatal编程技术网

Javascript typeError:(0,_reactRedux.connect)不是函数

Javascript typeError:(0,_reactRedux.connect)不是函数,javascript,react-native,redux,Javascript,React Native,Redux,由于错误,我无法显示我的react本机应用程序。 我已经看了这里的其他类似帖子,但没有回答我的问题 下面是一些代码: import React, {Component} from 'react'; import {View, Text, StyleSheet, Image,TouchableOpacity,Button} from 'react-native'; import TopNavbar from './TopNavbar'; import { connect } from 'react

由于错误,我无法显示我的react本机应用程序。 我已经看了这里的其他类似帖子,但没有回答我的问题

下面是一些代码:

import React, {Component} from 'react';
import {View, Text, StyleSheet, Image,TouchableOpacity,Button} from 'react-native';
import TopNavbar from './TopNavbar';
import { connect } from 'react-redux';
import {addIncrement, addDecrement} from '../redux/actions'

class Insigts extends Component {

    componentDidMount(){
        this.props.addIncrement
    }
    render(){
        const { counter } = this.props
        return(
            <View style={styles.container}>
                a lot of other elements etc... 
            </View>
        )
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        marginTop: 40,
    },
    somestyle: {
      style style style
});


const mapStateToProps = (state) => {
    return {
        counter: state.counter
    }
}

const mapDispatchToProps = (dispatch) => {
    return {
    addIncrement: () => dispatch(addIncrement()),
    addDecrement: () => dispatch(addDecrement()),    
    }
}

export default connect(
    mapStateToProps,
    mapDispatchToProps,
    )(Insigts)
import React,{Component}来自'React';
从'react-native'导入{视图、文本、样式表、图像、TouchableOpacity、按钮};
从“/TopNavbar”导入TopNavbar;
从'react redux'导入{connect};
从“../redux/actions”导入{addIncrement,addDecrement}
类Insigts扩展了组件{
componentDidMount(){
这是额外的
}
render(){
const{counter}=this.props
返回(
很多其他元素等等。。。
)
}
}
const styles=StyleSheet.create({
容器:{
弹性:1,
玛金托普:40,
},
某种风格:{
风格风格
});
常量mapStateToProps=(状态)=>{
返回{
计数器:state.counter
}
}
const mapDispatchToProps=(调度)=>{
返回{
addIncrement:()=>分派(addIncrement()),
addDecrement:()=>分派(addDecrement()),
}
}
导出默认连接(
MapStateTops,
mapDispatchToProps,
)(Insigts)

我已经安装了所有的软件包并尝试重新启动模拟器,但没有成功。

是否安装了
react-redux
?它显然是想告诉你
connect
不是一个函数,所以你的导入有问题。试着重新安装/清除你的npm缓存。@FrankerZ,我重新安装了react-redux并重新安装了e npm缓存,但没有成功。如果我刷新应用程序,我会让它工作,但一旦我将代码保存在VS代码中,错误会再次弹出。