Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.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:对象(…)不是函数-Redux-React路由器_Javascript_Reactjs_Redux_React Router_Typeerror - Fatal编程技术网

Javascript TypeError:对象(…)不是函数-Redux-React路由器

Javascript TypeError:对象(…)不是函数-Redux-React路由器,javascript,reactjs,redux,react-router,typeerror,Javascript,Reactjs,Redux,React Router,Typeerror,当我尝试运行react应用程序时,我得到了这样一个“TypeError:Object(…)不是函数” 我在redux的存储中得到了错误。我不知道为什么我会出现这个错误,这是因为它与路由器有关 这是我的档案 这是我的Reducers文件夹中的Reducers 以及存储文件夹中的存储-从该文件中获取错误,或者我不知道从何处显示的确切信息 import { createStore } from 'react' import authstate from '../reducers/reducers'

当我尝试运行react应用程序时,我得到了这样一个“TypeError:Object(…)不是函数”

我在redux的存储中得到了错误。我不知道为什么我会出现这个错误,这是因为它与路由器有关

这是我的档案

这是我的Reducers文件夹中的Reducers

以及存储文件夹中的存储-从该文件中获取错误,或者我不知道从何处显示的确切信息

import { createStore } from 'react'
import authstate from '../reducers/reducers'

const store = createStore(authstate);

export default store;
最后是我分派动作的组件

从“React”导入React;
从“react redux”导入{connect}
从“../../Redux/action/actions”导入Auth_True
从“../../Redux/action/actions”导入Auth_False
类登录扩展了React.Component{
render(){
返回(
身份验证状态:{this.props.Auth}
实现
设假
);
}
}
const mapStatesToProps=状态=>{
返回{
Auth:state.Auth\u state
}
}
const mapDispatchToProps=调度=>{
返回{
更改_state_true:()=>调度(Auth_true()),
更改_状态_false:()=>调度(Auth_false())
}
}
导出默认连接(MapStateStorops、mapDispatchToProps)(登录);

你们能帮我理解为什么会发生这种情况吗?这是因为React路由器或我分派的组件的连接功能,还是redux和React的版本不支持。

而不是从“React”导入{createStore}


尝试从'redux'导入{createStore}

createStore
是从
redux
导出的,而不是
react
我做了您所说的更改,按下login组件中的SET TRUE(设置为真)按钮后,我得到了相同的错误。我该怎么办?你能把你的代码发布到codesandbox.io并给我一个链接吗?
const Auth_True =  () => {
 return{
    type: 'Auth_True',
    Auth_State: true
  }
  }

   const Auth_False =  () => {
     return{
        type: 'Auth_False',
         Auth_State: false
     }
     }


  export default {Auth_False,Auth_True};
const intialState = {
Auth_state : false
}

const authstate = (state = intialState, action) => {
switch(action.type){
    case 'Auth_True':
        return{

            Auth_state: action.Auth_state
        }
    case 'Auth_False':
        return{

            Auth_state: action.Auth_state
        }
    default:
        return state;
}
} 

export default authstate;
import { createStore } from 'react'
import authstate from '../reducers/reducers'

const store = createStore(authstate);

export default store;
import React from 'react';
import { connect } from 'react-redux'
import Auth_True from '../../Redux/action/actions'
import Auth_False from '../../Redux/action/actions'


class Login extends React.Component{
   render(){
     return(
         <div>

            <div>
            <h3>Auth State : {this.props.Auth}</h3>
            <button onClick={this.props.change_state_true}>Set True</button>
            <button onClick={this.props.change_state_false}>Set False</button>
            </div>
         </div>

      );
      }
      }

      const mapStatesToProps = state => {
      return{
      Auth : state.Auth_State
      }
       }

      const mapDispatchToProps = dispatch => {
       return{
       change_state_true : () => dispatch(Auth_True()),
       change_state_false : () => dispatch(Auth_False())
         }
          }

       export default connect(mapStatesToProps,mapDispatchToProps)(Login);