forked from ihor/ReactNativeCodeReuseExample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAbstractHelpButtonContainer.js
35 lines (27 loc) · 1006 Bytes
/
AbstractHelpButtonContainer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react';
import PropTypes from 'prop-types';
import HelpButtonView from './HelpButtonView';
export default class AbstractHelpButtonContainer extends React.Component {
constructor(props) {
// new.target is not working on Android
// if (new.target === AbstractHelpButtonContainer) {
// throw new TypeError('Cannot construct AbstractHelpButtonContainer instances directly');
// }
super(props);
this.onClick = this.onClick.bind(this);
}
onClick() {
this.displayMessage(`You asked for help ${this.props.helpRequests + 1} time(s)`);
this.props.helpRequested();
}
displayMessage(message) {
throw new TypeError('Abstract method displayMessage is not implemented');
}
render() {
return <HelpButtonView onClick={this.onClick}/>;
}
}
AbstractHelpButtonContainer.propTypes = {
helpRequests: PropTypes.number.isRequired,
helpRequested: PropTypes.func.isRequired,
};