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

How do you pass a Payload when you dispatch an action? #51

Open
Stophface opened this issue Feb 11, 2022 · 3 comments
Open

How do you pass a Payload when you dispatch an action? #51

Stophface opened this issue Feb 11, 2022 · 3 comments

Comments

@Stophface
Copy link

From the code side I dispatch my action like this

    dispatch({
        type: DO_SOMETHING,
        payload: {
            foo: 'cat',
            bar: 'dog'
        }
    });

When I try to dispatch this action with a payload from the flipper plug in

{
    'foo': 'cat',
    'bar': 'dog'
}

It tells me undefined is not an object and pin points me to action.payload.foo. So I assume the payload is not passed from the plug in. How do I give it a payload?

@Stophface Stophface changed the title Define Payload How do you pass a Payload when you dispatch an action? Feb 11, 2022
@iAmHarmon
Copy link

iAmHarmon commented Feb 27, 2022

You need to pass the object you would dispatch in your code to the plugin.
E.g.
{ type: DO_SOMETHING, payload: { foo: 'cat', bar: 'dog' } }

@plwai
Copy link
Collaborator

plwai commented Mar 3, 2022

In redux, even though payload is a standard but it is not a default field. The flexibility trade off requires user to supply the field name.

@uloco
Copy link

uloco commented Mar 17, 2022

If you have a payload which is not an object just pass {"payload": xxx}

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