我有以下项目结构 -
我有 GlobalStore.js,其中有以下代码:-
import React from 'react'
const GlobalContext=React.createContext();
const GlobalProvider=GlobalContext.Provider;
const GlobalConsumer=GlobalContext.Consumer;
export {GlobalProvider,GlobalConsumer}
LoginReducers/Login_Action.js 与以下代码 -
const VERIFY_CREDENTIALS ='VERIFY_CREDENTIALS'
export function VerifyCredentials()
{
return{
type :VERIFY_CREDENTIALS
}
}
LoginReducers/Login_Reducers.js 使用以下代码 -
import Axios from "axios";
import { VerifyCredentials } from "./Login_Action";
const initialState={
userName:"",
password:"",
isVarified:false
}
const url='http://localhost:52016/api/values/';
export const LoginReducer=(state=initialState,action)=>{
switch (action.type) {
case 'VERIFY_CREDENTIALS':
Axios.get(url)
.then(x=>{
alert(x.data);
})
default:
break;
}
}
GlobalStorage/store.js 与以下代码 -
import { createStore } from 'redux';
import { LoginReducer } from "../Components/LoginReducers/Login_Reducers";
export const store=createStore(LoginReducer);
带有以下代码的 App.js -
import logo from './logo.svg';
import './App.css';
import Login from './Components/Login';
import { store } from "./GlobalStorage/store";
import {GlobalProvider,GlobalConsumer} from "./GlobalStore";
function App() {
return (
<div className="App">
<GlobalProvider value={store}>
<Login></Login>
</GlobalProvider>
</div>
);
}
export default App;
我收到以下错误:-
请建议可以进行哪些更改以解决此错误?
还请建议是否推荐上述代码结构,我正在store通过GlobalProvider.

