Material UI v1 with Redux - How to Export

I am trying to use Material-UI v1 with the Stajuan Redux-Saga login template shown here . So, I want to combine the tag of export defaultthese two, in other words combine the two functions to export the default class:

import React, {Component} from 'react';
import { connect } from 'react-redux';
import { withStyles, createStyleSheet } from 'material-ui/styles';

// Redux
function select (state) {
    return {
    data: state
    }
}

// Material UI v1
const styleSheet = createStyleSheet(theme => ({
    // ...
}));

// Class to be exported
class Login extends Component {
    // ...
    render () {
        // ...
    }

}

// H O W   T O   M E R G E   T H O S E ? ? ?
// export default connect(select)(Login);
// export default withStyles(styleSheet)(Login);

The last two numbered lines of code above are statements that will be combined in my case.

+4
source share
2 answers

you need to install npm install recomposeoryarn add recompose

and in the export section

export default compose(
    withStyles(styles, {
        name: 'App',
    }),
    connect(),
)(AppFrame);

or you can do:

export default withStyles(styles)(connect(select))(Cart));

+3
source

this.props.domain

,

const mapStateToProps = state => {
    return { domain : 'yourdomain.com'
    }
}
export default withStyles(styles)(connect(mapStateToProps)(Login));
0

Source: https://habr.com/ru/post/1683715/


All Articles