bigbuffet-rw/app/soapbox/components/column_back_button.js

30 lines
773 B
JavaScript
Raw Normal View History

2020-03-27 13:59:38 -07:00
import React from 'react';
import { FormattedMessage } from 'react-intl';
import PropTypes from 'prop-types';
2020-05-28 15:52:07 -07:00
import Icon from 'soapbox/components/icon';
2020-03-27 13:59:38 -07:00
export default class ColumnBackButton extends React.PureComponent {
static contextTypes = {
router: PropTypes.object,
};
handleClick = () => {
if (window.history && window.history.length === 1) {
2020-04-10 18:10:39 -07:00
this.context.router.history.push('/');
2020-03-27 13:59:38 -07:00
} else {
this.context.router.history.goBack();
}
}
render() {
2020-03-27 13:59:38 -07:00
return (
<button onClick={this.handleClick} className='column-back-button'>
<Icon id='chevron-left' className='column-back-button__icon' fixedWidth />
<FormattedMessage id='column_back_button.label' defaultMessage='Back' />
</button>
);
}
}