Browse Source

fix: init forum after login successfully instead of componentDidMount

pull/1/head
kdxcxs 4 years ago
parent
commit
70bfda1368
  1. 9
      src/YooRouter.js
  2. 4
      src/component/YooForum.js

9
src/YooRouter.js

@ -15,6 +15,12 @@ export default class YooRouter extends Component {
}; };
this.gotoForum = this.gotoForum.bind(this); this.gotoForum = this.gotoForum.bind(this);
this.gotoLogin = this.gotoLogin.bind(this); this.gotoLogin = this.gotoLogin.bind(this);
this.bindForumInitializer = this.bindForumInitializer.bind(this);
this.initForum = null;
}
bindForumInitializer(forumRef) {
this.initForum = forumRef.initForum;
} }
gotoLogin() { gotoLogin() {
@ -34,6 +40,7 @@ export default class YooRouter extends Component {
} }
gotoForum() { gotoForum() {
this.initForum();
if (this.state.currentPage === 'splash') { if (this.state.currentPage === 'splash') {
Animated.parallel([ Animated.parallel([
Animated.timing(this.state.splashX, { Animated.timing(this.state.splashX, {
@ -73,7 +80,7 @@ export default class YooRouter extends Component {
<YooLogin gotoForum={this.gotoForum} /> <YooLogin gotoForum={this.gotoForum} />
</Animated.View> </Animated.View>
<Animated.View style={{left: this.state.forumX}}> <Animated.View style={{left: this.state.forumX}}>
<YooForum /> <YooForum bindInitializer={this.bindForumInitializer} />
</Animated.View> </Animated.View>
</View> </View>
); );

4
src/component/YooForum.js

@ -17,6 +17,10 @@ export default class YooForum extends Component {
this.initForum(); this.initForum();
} }
componentDidMount() {
this.props.bindInitializer(this);
}
initForum() { initForum() {
// get dwr session id // get dwr session id
gbkFetch( gbkFetch(

Loading…
Cancel
Save