Не могу вывести props в консоль. Именно в функциональном компоненте.
В классовых все работает нормально. Вроде подключение к redux есть. Единственное что пишет, это то что props undifined
import { connect } from 'react-redux';
export function listСategories(props) {
const string = 'Hello world';
console.log(props.gamedata.numQues);
return string;
}
const mapStateToProps = state => ({
gamedata: state.questions.data,
user: state.user.data,
screen: state.screen.screenState,
allquestions: state.allquestions.data,
});
export default connect(mapStateToProps)(listСategories);
Вот в классовом все нормально:
import React, { Component } from 'react';
import { styles } from '../styles';
import { View, Text } from 'react-native';
import { connect } from 'react-redux';
class Progressbar extends Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
let result = [...Array(this.props.gamedata.numQues)].map((item, index, arr) => {
let color;
if(this.props.gamedata.right.includes(index)){
color = 'green';
}else if(this.props.gamedata.wrong.includes(index)){
color = 'red';
}else{
color = 'blue';
}
return (
<View key={index} style={{width: 20, height: 20, borderRadius: 100/2, backgroundColor: `${color}`, marginBottom: 10}} />
)
});
return (
<View style={{flexDirection: 'row', justifyContent: 'center', flexWrap: 'wrap'}}>
{result}
</View>
);
}
}
const mapStateToProps = state => ({
gamedata: state.questions.data,
user: state.user.data,
screen: state.screen.screenState,
});
export default connect(mapStateToProps)(Progressbar);