zalmoxisus / redux-devtools-extension

Redux DevTools extension.
MIT License
13.5k stars 1.01k forks source link

Access the redux store information from outside of the application. #607

Open stephan-v opened 5 years ago

stephan-v commented 5 years ago

Is there any way to read the information that is currently in the redux store from outside of the application?

In react this would be possible by doing something like this before the react application is set up:

window.__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
    supportsFiber: true,

    inject: function(react) {
        console.log('inject', react);
    },

    onCommitFiberRoot: function (rendererID, root) {
        console.log('this is an initialized react app', root);
    },

    onCommitFiberUnmount: function (rendererID, fiber) {
        console.log('unmount', arguments);
    }
};

Essentially you are faking a devtools plugin which is not there and mocking up your own object with the hooks that are in the react-devtools repository.

zalmoxisus commented 5 years ago

We're not exposing the store object on purpose as many are using it in production. That can be easily done by just adding window.store = store in your store creator or by adding a custom store enhancer.

But there's a plan for future versions to have a button to expose it when needed, together with the actions/states history for debugging from the console.

stephan-v commented 5 years ago

I do not have access to the store that is being created though. I am looking for a way to scrap a third party redux store.

zalmoxisus commented 5 years ago

@stephan-v for now you can get it from Redux DevTools, just click on Provider component and it'll be in props, which can be accessed from $r. Or you can get it from Sources like here.