![](/img/trans.png)
[英]Material-UI DataGrid Column Filter doesn't work with Material-UI Dialog
[英]Calling action creator for onClick event on a material-ui button doesn't work
當我為材質ui RaisedButton上的onClick事件調用動作創建者時,出現以下錯誤
道具類型失敗:提供給RaisedButton
object
類型prop的無效道具onClick
,預期function
。
這是我寫的組件
import React, { Component } from 'react';
import RaisedButton from 'material-ui/RaisedButton';
import { connect } from 'react-redux';
import * as actions from '../actions';
class App extends Component {
authButton = () => {
if(this.props.authenticated) {
return <RaisedButton label="Sign out" onClick={this.props.authenticate(false)} />
}
return <RaisedButton label="Sign out" onClick={this.props.authenticate(true)} />
}
render() {
return (
<div>{this.authButton()}</div>
);
}
}
const mapStateToProps = (state) => {
return { authenticated: state.authenticated };
}
export default connect(mapStateToProps, actions)(App);
如何擺脫這個錯誤並使之發揮作用?
它期望功能,所以嘗試這個
onClick={() => { this.props.authenticate(false)}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.