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

v4 examples are broken because the actions argument is missing #84

Closed
SaphuA opened this issue Sep 21, 2018 · 3 comments
Closed

v4 examples are broken because the actions argument is missing #84

SaphuA opened this issue Sep 21, 2018 · 3 comments

Comments

@SaphuA
Copy link

SaphuA commented Sep 21, 2018

Working on converting a working v3 implementation to v4, but I'm having some issues.

I renamed actions in the config to actionsCreators and initStore to createStore. Then in my consuming component I also added actions to the import from the store.

My config looks like this:

const config = {
    initialState: {
        files: [],
    },
    actionsCreators: {
        addFile: (state, fileName) => {
            // ...
        }
    }
}

The function in the component triggering the action now looks like this (where it would first do this.props.actions...):

addFile = () => {
    actions.addFile(this.state.text);
}

But when the action is called the param fileName is an object containing all the actions instead of the provided value.

Am I missing something here or is something fishy going on? (Working in typescript / webpack so might also be a compilation issue?)

@SaphuA
Copy link
Author

SaphuA commented Sep 21, 2018

Wait.. is this by design?

const result = actionsCreators[v](state, actions, ...args)

That would mean that this example should not be working anymore?

addTodo: ({ todos }, todo) => ({

And instead should be:

addTodo: ({ todos }, actions, todo) => ({

@didierfranc If you can give me some confirmation I wouldn't mind updating the examples / docs.

@tonthanhhung
Copy link

tonthanhhung commented Sep 28, 2018

I'm also interested in why the author changed this, is it something could be documented ? Why we need action in another action ?, is it for chainable action ?

@didierfranc
Copy link
Owner

I'll check examples and update them with v4 final ;)

@SaphuA SaphuA changed the title Migrating from v3 to v4 action's second argument are actions? v4 examples are broken because the actions argument is missing Oct 18, 2018
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

3 participants