Skip to content

Ability to obtain store in a component #948

Closed
@sodik82

Description

@sodik82

Hi there,

this is most likely a question or enhancement proposal. I know that I could get store by using old context API - but this looks not to be part of official API. It looks to me like the internal implementation that can change (e.g. with new React Context implementation). Is there a official way to retrieve the store?

My motivation:
I am using redux-saga and I like the way how they "enhanced" store in their example in official API

export default function configureStore(initialState) {
  // Note: passing middleware as the last argument to createStore requires redux@>=3.1.0
  const sagaMiddleware = createSagaMiddleware()
  return {
    ...createStore(reducer, initialState, applyMiddleware(/* other middleware, */sagaMiddleware)),
    runSaga: sagaMiddleware.run
  }
}

I would like to execute runSaga in my components and therefore need get the store. And as store is already provided by Provider it would be convenient to able to retrieve it somewhere down the road in official way.

I know that this is not direct responsibility of react-redux but I believe other users could benefit from (or misuse) such feature as well :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions