не могу понять почему эта проблема с thunk

64
08 февраля 2022, 07:20

APP

import React from 'react';
import logo from './logo.svg';
import './App.css';
import ComContainer from './comContainer'
function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />
        <p>
          Edit <code>src/App.js</code> and save to reload.
        </p>
        <ComContainer />
        <a
          className="App-link"
        >
          Learn React
        </a>
      </header>
    </div>
  );
}
export default App;

reducer

import axios from 'axios'
let initialState = {
    app:false,
    isFetcing:true,
    data:null
};
const reducer = (state = initialState, action) => {
    switch(action.type){
        case "test":
            return{state,data:action.data}
        default:
                return state
    }   
}
export const getUsers = (dispatch)=>{
    //https://jsonplaceholder.typicode.com/todos/1
    axios.get("https://jsonplaceholder.typicode.com/todos/1")
    .then((data)=>{
        dispatch({type:"test", data:data.data})
    })
}
export default reducer;

com

import React from 'react';
const Com = (props) => {
    console.log(props)
    return(
        <div>
            <p>com</p>
        </div>
    )
}
export default Com

comContainer

import React from 'react';
import {connect, Provider} from "react-redux";
import Com from './com'
import getUsers from './reducer'
class ComContaine extends React.Component{
    componentDidMount(){
        this.props.getUsers()
        }
    render(){
        return (
        <div><Com props={this.props} /></div>
        )
    }

}
const mapStateToProps = (state) => {
    return{
    reducerbla: state.reducer
    }
}
const sendMessage = (dispatch) => {
    dispatch({type:"tesfgst"});
}
/*const mapDispatchToProps = (dispatch) => {
    return{
        sendMessage: () => {
            dispatch({type:"tesfgst"});
        }
}
}*/
let ComContainer = connect(mapStateToProps,{sendMessage,getUsers})(ComContaine)
export default ComContainer

redux

import {applyMiddleware, combineReducers, compose, createStore} from "redux";
import reducer from './reducer'
import thunkMiddleware from "redux-thunk";

let reducers = combineReducers({
    reducer:reducer
});
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(reducers ,composeEnhancers(applyMiddleware(thunkMiddleware)));
window.__store__ = store;
export default store;

index js

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import {connect, Provider} from "react-redux";
import store from './redux'
ReactDOM.render(<Provider store={store}><App /></Provider>, document.getElementById('root'));
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers:
serviceWorker.unregister();

пишет следущее TypeError: Cannot read property 'type' of undefined похоже что-то не так с моей санкой помогите пожалуйста исправить ссылка на гит https://github.com/arsenii436/thunk

READ ALSO
Как сделать рандомный вычитатель чисел?

Как сделать рандомный вычитатель чисел?

Подскажите, пожалуйста, как сделать рандомное уменьшение числа в определённый промежуток времени? Те

67
Вывод select через button

Вывод select через button

При нажатии кнопки должна появится та часть массива которая указана в select

85