react-server icon indicating copy to clipboard operation
react-server copied to clipboard

handleRoute called twice, one on server, one on client

Open hong-duc opened this issue 8 years ago • 0 comments

I have a page that fetch data when request to page

export default class HomePage {
  handleRoute(next) {
    this.title = SettingService.getSetting('title_trang_chu').then(result => {
      return result.value.value;
    });
    return next();
  }

  getElements() { ........

But the SettingService.getSetting get called twice and that make 2 request to the api server.

But this only happen if the getElements method return some elements, if it return empty array handleRoute will not be called on the client

Is this the expected behaviour ? Or I am using it wrong ? I just want to fetch data once when there is a request to a page and then wait for the result then render page

Thank you

hong-duc avatar Dec 16 '17 04:12 hong-duc