From a2c88af59deb0e4b5a716805a64a7ac46c7bd8e1 Mon Sep 17 00:00:00 2001 From: Abhas Bhattacharya Date: Sun, 25 Mar 2018 06:21:16 +0530 Subject: [PATCH] Refactor dateswitchbar icon rotation logic --- src/Components/DateSwitchBar/Component.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Components/DateSwitchBar/Component.tsx b/src/Components/DateSwitchBar/Component.tsx index 9ef33cb..9245c08 100644 --- a/src/Components/DateSwitchBar/Component.tsx +++ b/src/Components/DateSwitchBar/Component.tsx @@ -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) {