Это мой homepage.js
import _ from 'lodash';
import React, { Component } from 'react';
import { View, FlatList } from 'react-native';
import { connect } from 'react-redux';
import { fetchGames } from '../actions';
import GameRowItem from './GameRowItem';
class Homepage extends Component {
componentWillMount() {
this.props.fetchGames({this.props.userInfo});
}
renderRow(game) {
return <GameRowItem game={game} />;
}
render() {
return (
<View style={{ flex: 1 }}>
<FlatList
data={this.props.games}
renderItem={this.renderRow}
keyExtractor={(game, index) => index.toString()}
/>
</View>
);
}
}
const mapStateToProps = state => {
const games = _.map(state.games, (val, uid) => {
return { ...val, uid };
});
return {
games,
userInfo: state.auth.userInfo
};
};
export default connect(mapStateToProps, { fetchGames })(Homepage);
Я хочу передать опору своему действию после запуска функции connect()
.Поскольку мне нужно состояние моего уровня приложения, и если я не смогу их достичь до запуска функции componentWillMount()
, я не могу получить свои игры должным образом ...
Я знаю, что сказал, что смешал все, и это трудноПонимаю.И все же я надеюсь, что кто-то меня поймет.