Skip to content

Commit

Permalink
Merge pull request #4625 from hhaidar/fix-ie-props-access
Browse files Browse the repository at this point in the history
[IE] Move state props access into componentWillMount for IE9/10
  • Loading branch information
oliviertassinari authored Jul 6, 2016
2 parents ed9f346 + 5a03dfa commit 7bf116d
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/DatePicker/DateDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,16 @@ class DateDisplay extends Component {
};

state = {
selectedYear: !this.props.monthDaySelected,
selectedYear: false,
transitionDirection: 'up',
};

componentWillMount() {
if (!this.props.monthDaySelected) {
this.setState({selectedYear: true});
}
}

componentWillReceiveProps(nextProps) {
if (nextProps.selectedDate !== this.props.selectedDate) {
const direction = nextProps.selectedDate > this.props.selectedDate ? 'up' : 'down';
Expand Down
8 changes: 7 additions & 1 deletion src/Table/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,15 @@ class Table extends Component {
};

state = {
allRowsSelected: this.props.allRowsSelected,
allRowsSelected: false,
};

componentWillMount() {
if (this.props.allRowsSelected) {
this.setState({allRowsSelected: true});
}
}

isScrollbarVisible() {
const tableDivHeight = this.refs.tableDiv.clientHeight;
const tableBodyHeight = this.refs.tableBody.clientHeight;
Expand Down
6 changes: 5 additions & 1 deletion src/Table/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,13 @@ class TableBody extends Component {
};

state = {
selectedRows: this.calculatePreselectedRows(this.props),
selectedRows: [],
};

componentWillMount() {
this.setState({selectedRows: this.calculatePreselectedRows(this.props)});
}

componentWillReceiveProps(nextProps) {
if (this.props.allRowsSelected && !nextProps.allRowsSelected) {
this.setState({
Expand Down
8 changes: 7 additions & 1 deletion src/TextField/EnhancedTextarea.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,15 @@ class EnhancedTextarea extends Component {
};

state = {
height: this.props.rows * rowsHeight,
height: null,
};

componentWillMount() {
this.setState({
height: this.props.rows * rowsHeight,
});
}

componentDidMount() {
this.syncHeightWithShadow();
}
Expand Down
8 changes: 7 additions & 1 deletion src/TimePicker/Clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ class Clock extends Component {
};

state = {
selectedTime: this.props.initialTime || new Date(),
selectedTime: null,
mode: 'hour',
};

componentWillMount() {
this.setState({
selectedTime: this.props.initialTime || new Date(),
});
}

setMode = (mode) => {
setTimeout(() => {
this.setState({
Expand Down
8 changes: 7 additions & 1 deletion src/TimePicker/ClockPointer.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,15 @@ class ClockPointer extends Component {
};

state = {
inner: isInner(this.props),
inner: false,
};

componentWillMount() {
this.setState({
inner: isInner(this.props),
});
}

componentWillReceiveProps(nextProps) {
this.setState({
inner: isInner(nextProps),
Expand Down
8 changes: 7 additions & 1 deletion src/TimePicker/TimePicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,16 @@ class TimePicker extends Component {
};

state = {
time: this.isControlled() ? this.getControlledTime() : this.props.defaultTime,
time: null,
dialogTime: new Date(),
};

componentWillMount() {
this.setState({
time: this.isControlled() ? this.getControlledTime() : this.props.defaultTime,
});
}

componentWillReceiveProps(nextProps) {
if (nextProps.value !== this.props.value) {
this.setState({
Expand Down

0 comments on commit 7bf116d

Please sign in to comment.