-
Notifications
You must be signed in to change notification settings - Fork 860
Expand file tree
/
Copy pathFormulaeBase.js
More file actions
47 lines (36 loc) · 1014 Bytes
/
FormulaeBase.js
File metadata and controls
47 lines (36 loc) · 1014 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
'use strict';
import { Component } from 'react';
import CalculatorStore from '../stores/CalculatorStore';
import CalculatorActions from '../actions/CalculatorActions';
function getCalculatorState() {
return {
displayFormulae: CalculatorStore.getDisplayFormulae()
};
}
class Formulae extends Component {
constructor(props) {
super(props);
this.state = {
displayFormulae: CalculatorStore.getDisplayFormulae()
};
// Bind callback methods to make `this` the correct context.
this.handleClick = this.handleClick.bind(this);
this._onChange = this._onChange.bind(this);
}
componentDidMount() {
CalculatorStore.addChangeListener(this._onChange);
}
componentWillUnmount() {
CalculatorStore.removeChangeListener(this._onChange);
}
dynamicClass(operator) {
return 'group ' + operator;
}
handleClick(formula) {
CalculatorActions.typeFormula(formula);
}
_onChange() {
this.setState(getCalculatorState());
}
}
export default Formulae;