check this.container exists updating WiderPadding (#6976)

before doing updating wider padding for Card, always check if the container exists first.
This commit is contained in:
Neekey 2017-07-29 16:12:53 +10:00 committed by 偏右
parent d6a0b1bd3e
commit 6eff4bd02a

View File

@ -41,17 +41,19 @@ export default class Card extends Component<CardProps> {
}
@throttleByAnimationFrameDecorator()
updateWiderPadding() {
// 936 is a magic card width pixer number indicated by designer
const WIDTH_BOUDARY_PX = 936;
if (this.container.offsetWidth >= WIDTH_BOUDARY_PX && !this.state.widerPadding) {
this.setState({ widerPadding: true }, () => {
this.updateWiderPaddingCalled = true; // first render without css transition
});
}
if (this.container.offsetWidth < WIDTH_BOUDARY_PX && this.state.widerPadding) {
this.setState({ widerPadding: false }, () => {
this.updateWiderPaddingCalled = true; // first render without css transition
});
if (this.container) {
// 936 is a magic card width pixer number indicated by designer
const WIDTH_BOUDARY_PX = 936;
if (this.container.offsetWidth >= WIDTH_BOUDARY_PX && !this.state.widerPadding) {
this.setState({ widerPadding: true }, () => {
this.updateWiderPaddingCalled = true; // first render without css transition
});
}
if (this.container.offsetWidth < WIDTH_BOUDARY_PX && this.state.widerPadding) {
this.setState({ widerPadding: false }, () => {
this.updateWiderPaddingCalled = true; // first render without css transition
});
}
}
}
saveRef = (node: HTMLDivElement) => {