Refactor dateswitchbar icon rotation logic

This commit is contained in:
2018-03-25 06:21:16 +05:30
parent 3c68b88ceb
commit a2c88af59d
+10 -10
View File
@@ -6,23 +6,23 @@ export class DateSwitchBar extends React.Component<{}, { rotated: boolean }> {
constructor(props: {}) {
super(props);
this.updateFromProps(props);
this.state = { rotated: false };
this.willBeCreated(props);
}
componentDidMount() {
this.afterUpdated();
}
willBeCreated(props: {}) {
this.setState({ rotated: false });
}
afterUpdated() {
setTimeout(() => { this.setState({ rotated: true }); }, 1000);
}
componentWillUpdate(nextProps: {}, nextState: {}) {
this.updateFromProps(nextProps);
}
updateFromProps(props: {}) {
// do nothing for now
}
render() {
const iconClasses = ["icon"];
if (this.state.rotated) {