AG-1053 Tidy react examples, make more idiomatic
This commit is contained in:
31
src-examples/dynamicComponentExample/CurrencyRenderer.jsx
Normal file
31
src-examples/dynamicComponentExample/CurrencyRenderer.jsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import React, {Component} from "react";
|
||||
|
||||
export default class CurrencyRenderer extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
value: props.value
|
||||
}
|
||||
}
|
||||
|
||||
static formatValueToCurrency(currency, value) {
|
||||
return `${currency}${value}`
|
||||
}
|
||||
|
||||
// noinspection JSUnusedGlobalSymbols
|
||||
refresh(params) {
|
||||
if(params.value !== this.state.value) {
|
||||
this.setState({
|
||||
value: params.value.toFixed(2)
|
||||
})
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<span>{CurrencyRenderer.formatValueToCurrency('EUR', this.state.value)}</span>
|
||||
);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user