All components - update correctly on both prop create and update

This commit is contained in:
2018-03-23 00:39:49 +05:30
parent 1ffb373d2b
commit 508c034276
4 changed files with 44 additions and 10 deletions
+8
View File
@@ -21,6 +21,14 @@ export class OpenXDay extends React.Component<OpenXDayProps, {}> {
constructor(props: OpenXDayProps) {
super(props);
this.updateFromProps(props);
}
componentWillUpdate(nextProps: OpenXDayProps, nextState: {}) {
this.updateFromProps(nextProps);
}
updateFromProps(props: OpenXDayProps) {
this.question = props.question;
this.xDay = props.xDay;
this.allHolidays = props.allHolidays;