0
宣布我实施的一个项目变化状态JSX
class MainSwiper extends React.Component {
_onMomentumScrollEnd() {
// Edit some state of the SomeView here...
}
render() {
return (
<Swiper
onMomentumScrollEnd={this._onMomentumScrollEnd}>
<View>
<SomeView />
</View>
// More views here...
</Swiper>
);
}
}
AppRegistry.registerComponent('some_app',() => MainSwiper);
的反应本地刷卡(https://github.com/leecade/react-native-swiper),我想的方法_onMomentumScrollEnd()
改变的JSX宣布SomeView
的一些状态。
假设SomeView
被定义为:
class SomeView extends React.Component {
constructor(props) {
super(props);
this.state = {somestate = 'Hi!'};
}
render() {
return (
<Text>{this.state.somestate}</Text>
);
}
}
我意识到我可能会在错误的方式来处理这个问题,但我不知道它是如何做。 somestate
如何从_onMomentumScrollEnd()
(或任何其他MainSwiper
方法)更改并获得SomeView
重新呈现,即如何从MainSwiper
方法访问SomeView
元素?