Use ES Class Fields & Static Properties (#3008)
Use ES Class Fields & Static Properties (currently stage 2) for improve class outlook. Added babel-plugin-transform-class-properties as a Babel plugin.
This commit is contained in:
committed by
Eugen Rochko
parent
44a3584e2d
commit
2991a7cfe6
@ -14,25 +14,26 @@ const messages = defineMessages({
|
||||
|
||||
class MediaModal extends ImmutablePureComponent {
|
||||
|
||||
constructor (props, context) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
index: null
|
||||
};
|
||||
this.handleNextClick = this.handleNextClick.bind(this);
|
||||
this.handlePrevClick = this.handlePrevClick.bind(this);
|
||||
this.handleKeyUp = this.handleKeyUp.bind(this);
|
||||
}
|
||||
static propTypes = {
|
||||
media: ImmutablePropTypes.list.isRequired,
|
||||
index: PropTypes.number.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
handleNextClick () {
|
||||
state = {
|
||||
index: null
|
||||
};
|
||||
|
||||
handleNextClick = () => {
|
||||
this.setState({ index: (this.getIndex() + 1) % this.props.media.size});
|
||||
}
|
||||
|
||||
handlePrevClick () {
|
||||
handlePrevClick = () => {
|
||||
this.setState({ index: (this.getIndex() - 1) % this.props.media.size});
|
||||
}
|
||||
|
||||
handleKeyUp (e) {
|
||||
handleKeyUp = (e) => {
|
||||
switch(e.key) {
|
||||
case 'ArrowLeft':
|
||||
this.handlePrevClick();
|
||||
@ -93,11 +94,4 @@ class MediaModal extends ImmutablePureComponent {
|
||||
|
||||
}
|
||||
|
||||
MediaModal.propTypes = {
|
||||
media: ImmutablePropTypes.list.isRequired,
|
||||
index: PropTypes.number.isRequired,
|
||||
onClose: PropTypes.func.isRequired,
|
||||
intl: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default injectIntl(MediaModal);
|
||||
|
Reference in New Issue
Block a user