n6g7/httpdf

Support async processing

Closed this issue · 0 comments

n6g7 commented

Components are rendered synchronously which means we can't do any async processing before rendering a file.

We could support a pre-render async method in the component class which could return initial props (à la getInitialProps).

class Test extends PureComponent {
  static document = true

  static async getInitialProps(props) {
     return {
      ...props,
      api: await myApi()
    }
  }

  render() {
    ...
  }
}