0
ReactCSSTransitionGroup對我不做任何事情,除了延遲我想要顯示的元素。我試圖讓我的組件在頁面加載時淡入。這是有問題的代碼:ReactCSSTransitionGroup不會激活轉換
import React from 'react';
import ReactCSSTransitionGroup from 'react/lib/ReactCSSTransitionGroup';
...
render() {
if(this.state.mounted) {
var child = (
<div>
<h1>{this.state.title}</h1>
<p>Description: {this.state.description}</p>
<p>Language(s): {this.state.lang}</p>
</div>
);
}
else {
var child = null;
}
return (
<div className="container">
<ReactCSSTransitionGroup transitionAppear={true} transitionAppearTimeout={1000} transitionName="puzzle" transitionEnterTimeout={500} transitionLeaveTimeout={300}>
{child}
</ReactCSSTransitionGroup>
</div>
)
}
,這裏是寫在SASS的CSS:
.puzzle-appear {
opacity: .01;
.puzzle-appear-active {
opacity: 1;
transition: opacity 1000ms ease-in;
};
};
.puzzle-enter {
opacity: .01;
.puzzle-enter-active {
opacity: 1;
transition: opacity 500ms ease-in;
};
};
.puzzle-leave {
opacity: 1;
.puzzle-leave-active {
opacity: .01;
transition: opacity 300ms ease-in;
};
};
我已經嘗試了一些事情,谷歌提供的,但沒有奏效。然而,一切似乎都是有序的。代碼有什麼問題?
您是否在控制檯中發現任何錯誤?它一直在工作嗎? –
對不起,我應該澄清一點。在控制檯中沒有錯誤,但組件確實呈現,沒有轉換。 – user75454