2017-08-14 53 views
4

我試圖與here顯示stajuan的終極版 - 佐賀登錄模板使用Material-UI v1。所以,我要合併的export default事情的兩個人,在結合兩種功能導出默認的類換句話說:材料UI V1與終極版 - 如何導出

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); 

最後兩個註釋掉的代碼行上方都成爲報表結合在我的情況。

+1

見本我的回答:https://stackoverflow.com/questions/45704681/react-material-ui-export-multiple-higher-order-components –

回答

3

你需要安裝npm install recomposeyarn add recompose

,並在您的出口部分

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

,或者你可以這樣做:

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

0

您將能夠與鍵訪問

this.props.domain 

添加以下行來導出類

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