byte-fe / react-model

The next generation state management library for React
236 stars 23 forks source link

pass params to getInitialState #32

Closed ArrayZoneYour closed 5 years ago

ArrayZoneYour commented 5 years ago

Background:

Sometimes we need to pass request info to send requests when use SSR. Like:

MyApp.getInitialProps = async ({ req }) => {
  if (!(process as any).browser) {
    const initialModels = await getInitialState(req)
    return { initialModels }
  } else {
    return { persistModel }
  }
}

expected

Support passing params to getInitialState.

behavior now

Don't support.

ArrayZoneYour commented 5 years ago

34