pass in prop onClick by default

This commit is contained in:
Luke Barnard 2016-11-10 17:30:35 +00:00
parent 87e8f0e4da
commit 0695037f5f

View file

@ -29,7 +29,9 @@ module.exports = React.createClass({
width: React.PropTypes.number, width: React.PropTypes.number,
height: React.PropTypes.number, height: React.PropTypes.number,
resizeMethod: React.PropTypes.string, resizeMethod: React.PropTypes.string,
// Whether the onClick of the avatar should dispatch 'view_user' // The onClick to give the avatar
onClick: React.PropTypes.function,
// Whether the onClick of the avatar should be overriden to dispatch 'view_user'
viewUserOnClick: React.PropTypes.boolean, viewUserOnClick: React.PropTypes.boolean,
}, },
@ -67,9 +69,8 @@ module.exports = React.createClass({
render: function() { render: function() {
var BaseAvatar = sdk.getComponent("avatars.BaseAvatar"); var BaseAvatar = sdk.getComponent("avatars.BaseAvatar");
var {member, ...otherProps} = this.props; var {member, onClick, ...otherProps} = this.props;
var onClick = null;
if (this.props.viewUserOnClick) { if (this.props.viewUserOnClick) {
onClick = () => { onClick = () => {
dispatcher.dispatch({ dispatcher.dispatch({