0
A
回答
1
我有改變的代碼在你的應用程序,請檢查在這裏Demo
import React from 'react'
import {render} from 'react-dom'
import { CSSTransitionGroup } from 'react-transition-group'
class SendData extends React.Component{
constructor(props) {
super(props);
this.state = {
images: [
'http://via.placeholder.com/350x150',
'http://via.placeholder.com/350x151'
],
currentImage: 0
};
this.fadeImage=this.fadeImage.bind(this);
}
fadeImage(e) {
e.preventDefault();
this.setState({currentImage: (this.state.currentImage + 1) % this.state.images.length})
}
render()
{
return(
<FadeImage images={this.state.images} currentImage={this.state.currentImage} fadeImage={this.fadeImage}/>
)
}
}
class FadeImage extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="image">
<CSSTransitionGroup
transitionName="example"
transitionEnterTimeout={300}
transitionLeaveTimeout={300}
>
<section>
<button className="button" onClick={this.props.fadeImage.bind(this)}>Click!</button>
<img src={this.props.images[this.props.currentImage]}/></section>
</CSSTransitionGroup>
</div>
);
}
}
render(<SendData />, document.querySelector('#app'))
相關問題
- 1. ReactJS組件的使用道具或國家決策呈現
- 2. 從經度獲取國家
- 3. 從tzInfo TimeZone獲取國家?
- 4. reactjs - 從api獲取數據
- 5. 無法從道具中獲取數據
- 6. C#:從國家代碼獲取國家名稱
- 7. 從國家或國家代碼獲取電話代碼 - Twilio
- 8. 從國家代碼在python中獲取國家名稱?
- 9. 從國家代碼中獲取國家/地區名稱
- 10. 代理/從其他國家獲取數據
- 11. ReactJS不能與狀態,錯誤獲取:「無法讀取空的特性‘國家’」
- 12. reactjs保留道具道具
- 13. 國家代碼不是從Android中的國家/地區代碼選取器中獲取的
- 14. 如何根據國家選擇的軌道選擇國家?
- 15. 國家不是根據選定的國家加載
- 16. 獲取國家名稱android
- 17. 獲取用戶的國家
- 18. 獲取ISO國家代碼
- 19. Python/Django從IP獲得國家國旗
- 20. ReactJS獲取JSON數據
- 21. 爲什麼當國家對ReactJs
- 22. 如何從家鄉ID獲取用戶的國家?
- 23. 如何從angularjs中的國家/地區獲取國家/地區名稱
- 24. 從國家代碼獲取國家/地區名稱字符串int
- 25. ReactJS - 道具或propTypes?
- 26. ReactJS:傳輸道具
- 27. 從道具數據的Reactjs下拉列表人口
- 28. Spotify API:根據名稱獲取藝術家而不是藝術家的ID
- 29. 如何從着色圖中獲取國家數量?
- 30. ISO國家/貨幣數據
國家是使用一個組件,而道具是用從一個組件傳遞到另一個價值,現在告訴我,爲什麼你需要的狀態道具中的數據?或讓我知道你想在你的示例應用程序中做什麼? –
我想從另一個組件再次收集道具的數據,所以我必須用無狀態組件重新組織這個數據 – Alex