brocoders / redux-async-connect

It allows you to request async data, store them in redux state and connect them to your react component.
645 stars 103 forks source link

How to access props in reduxAsyncConnect function? #101

Closed greyvugrin closed 7 years ago

greyvugrin commented 7 years ago

Following the example from the docs, but can't seem to get access to props at this stage.

static reduxAsyncConnect(params, store, helpers) {
    const {dispatch, getState} = store
    console.log(this)
    const { videoId } = this.props
    if (!isLoaded(getState())) {
      return dispatch(getVideo(videoId))
    }
  }

Unless I'm missing something and you would have to provide a videoID in some other way? Are props just not available at this point?

greyvugrin commented 7 years ago

Tried hard coding the ID for now, now running into ReferenceError: isLoaded is not defined

greyvugrin commented 7 years ago

Disregard this, for anoyone wondering, isLoaded is BYOF (build your own function). Check out https://github.com/erikras/react-redux-universal-hot-example/blob/master/src/containers/Widgets/Widgets.js for an example.