Не запускается функция mapStateToProps в connect()() react-native

Функция mapStateToProps не передаёт данные в connect()() и даже не запускается - debugger не отрабатывает внутри.

В пропсах всегда пустой объект!

export default function App() {
  //Тут всё приходит полный объект
    console.log(store.getState());
  return (
        <Provider store={store}>
            <View style={styles.container}>
                <Navbar />
                <GameContainer />
            </View>
        </Provider>
        );
}

import React, { useState } from 'react';
import { connect } from "react-redux";

import { setLevel } from '../redux/game-reducer';

import { Game } from './Game';


export class GameContainer extends React.Component {

    componentDidMount(){
        this.props.setLevel(1);
    }

    // render(){
    //  console.log(this.props);
    //  return <Game gameLevel={this.gameLevel} 
    //      imageModalVisible={this.props.imageModalVisible}
    //      imageModalImage={this.props.imageModalImage}
    //      wordLettersArray={this.wordLettersArray} />
    // }
    render(){
        console.log('Это пропсы');
        console.log(this.props); // Тут всегда пустой объект
        return <Game  />
    }
}

const mapStateToProps = (state) => {
    debugger; //Даже не отрабатывает, ф-я не запускается 
    return{
        game: state.gamePage
    // currentLevel: state.gamePage.currentLevel,
    // imageModalVisible: state.gamePage.imageModal, //.visible,
    // imageModalImage: state.gamePage.imageModal.image,
    // gameLevels: state.gamePage.levels,
}
};


const mapStateToDispatch = {setLevel};


export default connect(mapStateToProps, mapStateToDispatch)(GameContainer);

const SET_LEVEL = "SET_LEVEL";

const initialState = {
    currentLevel: 0,
    imageModal: { visible: false, image: '' },
    levels: [
        {
            level: 0,
            word: '',
            answer: '',
            exercise: [],
        }
    ]
    
};



const gameReducer = (state=initialState, action) => {
    switch (action.type) {
        case SET_LEVEL: {
            return {...state, ...state.levels, level: action};
        }

        default: {
            return state;
        }

    }

};



export const setLevel = (level) => ({
    type: SET_LEVEL,
    level
});

export default gameReducer;

import { combineReducers, createStore } from "redux";
import gameReducer from './game-reducer';




const reducers = combineReducers({
    gamePage: gameReducer
});

const store = createStore(reducers);

export default store;


Ответы (0 шт):