Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All actions are wrapped? #239

Closed
Anahkiasen opened this issue Nov 10, 2016 · 5 comments
Closed

All actions are wrapped? #239

Anahkiasen opened this issue Nov 10, 2016 · 5 comments

Comments

@Anahkiasen
Copy link

Anahkiasen commented Nov 10, 2016

I'm testing out the redux integration, but for some reason all my actions appear in Reactotron as wrapped in another action which makes it very hard to see at a glance what is happening:

screen shot 2016-11-10 at 13 11 39

Is this an option I have to configure or?

@rmevans9
Copy link
Collaborator

rmevans9 commented Nov 10, 2016

Can you show us how you are calling your actions? I ask this because I am not seeing this in my use of Reactotron.
screen shot 2016-11-10 at 7 16 05 am

Even with a payload I don't see this happening:
screen shot 2016-11-10 at 7 17 24 am

@Anahkiasen
Copy link
Author

Nevermind I've found what it is, it was redux devtool's composer that was adding its own wrapping to the actions:

const composeEnhancers = (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)
    ? window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__()
    : compose;

const store = Reactotron.createStore(reducers, initialState, composeEnhancers(middlewares));

If I switch it to just compose(middlewares) here it works

@rmevans9
Copy link
Collaborator

Good stuff!

@skellock
Copy link
Contributor

Ahh. You raise a good point here though.

I'm doing the same thing (in spirit) as @zalmoxisus. We're both trying to make sure we're in front & behind the call to create store so we can maintain references.

All Reactotron.createStore does is inject the right wrappers at the right time.

A short-term work around might be to do the work of Reactotron.createStore manually.

// first wrap your reducer to take advantage of Reactotron's state uploading/downloading
const tronducer = Reactotron.createReplacementReducer(rootReducer)

// add an additional enhancer to your list so we can monitor redux actions
const enhancers = composeEnhancers(middlewares, Reactotron.createActionTracker())

// then create your store as usual
const store = createStore(tronducer, enhancers)

// then tell Reactotron about the store so we're able to dispatch events & query the state tree from Reactotron
Reactotron.setReduxStore(store)

As a longer-term fix, I can probably detect window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__() and play nicely with redux dev tools.

Caveat: I didn't test that code, so this is pretty much me talking out of my ass right now. I feel like it should work tho. :)

@zalmoxisus
Copy link

zalmoxisus commented Nov 10, 2016

It's not directed related to the extension itself, but to redux-devtools-instrument's enhancer, which is lifting the store and should be always the last in the compose. window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ takes care of it, but lately it's wrapped by Reactotron's createStore.

@skellock's snippet should help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants