I\'m stuck on exporting material-ui styles with redux connector. Here is my code:
import React, { Component } from \'react\';
import { connect } from \'react
Complete Component
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import ExpansionPanel from "@material-ui/core/ExpansionPanel";
import ExpansionPanelSummary from "@material-ui/core/ExpansionPanelSummary";
import ExpansionPanelDetails from "@material-ui/core/ExpansionPanelDetails";
import Typography from "@material-ui/core/Typography";
import ExpandMoreIcon from "@material-ui/icons/ExpandMore";
import { withStyles } from "@material-ui/core/styles";
import { connect } from "react-redux";
import { fetchPosts } from "../../store/actions/postActions";
import PropTypes from "prop-types";
const useStyles = theme => ({
root: {
marginLeft: 250,
marginRight: 10
},
heading: {
fontSize: "1rem",
fontWeight: theme.typography.fontWeightRegular
}
});
class SimpleExpansionPanel extends React.Component {
UNSAFE_componentWillMount() {
this.props.fetchPosts();
}
UNSAFE_componentWillReceiveProps(nextProps) {
if (nextProps.newPost) {
this.props.postsa.unshift(nextProps.newPost);
}
}
render() {
const { classes } = this.props;
const postItem = this.props.postsa.map(post => (
}
aria-controls="panel1a-content"
id="panel1a-header">
{post.title}
{post.body}
));
return {postItem};
}
}
SimpleExpansionPanel.propTypes = {
fetchPosts: PropTypes.func.isRequired,
postsa: PropTypes.array.isRequired,
newPost: PropTypes.object
};
const mapStateToProps = state => ({
postsa: state.postss.items,
newPost: state.postss.item
});
export default connect(
mapStateToProps,
{ fetchPosts }
)(withStyles(useStyles)(SimpleExpansionPanel));