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. 從jVectormap獲取國家onregionclick
- 4. 從tzInfo TimeZone獲取國家?
- 5. reactjs - 從api獲取數據
- 6. 在Android中獲取國家的國家
- 7. 獲取在reactjs根元素道具
- 8. 無法從道具中獲取數據
- 9. 從Mysql獲取數據,而不是XML?
- 10. Reactjs道具是不是工作正常
- 11. 從國家/地區代碼獲取國家/地區名稱
- 12. C#:從國家代碼獲取國家名稱
- 13. 從國家代碼在python中獲取國家名稱?
- 14. 從國家代碼中獲取國家/地區名稱
- 15. 在IOS中從國家名稱獲取國家代碼
- 16. 從國家或國家代碼獲取電話代碼 - Twilio
- 17. 從過去3天從美國國家航空航天局API獲取數據
- 18. ReactJS不能與狀態,錯誤獲取:「無法讀取空的特性‘國家’」
- 19. 如何獲取國家名稱而不是兩位數字名稱
- 20. 從國家和狀態表獲取數據
- 21. 代理/從其他國家獲取數據
- 22. reactjs保留道具道具
- 23. 從座標獲取國家嗎?
- 24. 從AutoCompleteTextView獲取城市和國家
- 25. 從城市和州獲取國家
- 26. 從Facebook獲取用戶國家
- 27. 從iPhone獲取時區/國家
- 28. iptolatlng.com從IP php獲取國家名稱
- 29. 從一個國家獲取時區
- 30. 如何根據國家選擇的軌道選擇國家?
國家是使用一個組件,而道具是用從一個組件傳遞到另一個價值,現在告訴我,爲什麼你需要的狀態道具中的數據?或讓我知道你想在你的示例應用程序中做什麼? –
我想從另一個組件再次收集道具的數據,所以我必須用無狀態組件重新組織這個數據 – Alex