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

[6.0.0-rc.5] Unexpected behaviour when passing dispatch as prop to <Field /> #1567

Closed
brotzky opened this issue Aug 18, 2016 · 5 comments
Closed
Labels
Milestone

Comments

@brotzky
Copy link

brotzky commented Aug 18, 2016

I'm not able to pass dispatch directly into the Field component. It appears to be stripping any prop with the name dispatch. I'm not sure if this was on purpose, but the behaviour was surprising to me and not very intuitive.

A simplified version of what doesn't work:

render (
  const fieldProps = {
    dispatch, // passing dispatch into Field, along with other props
    ...
  };

 return <Field name="phone" component={Phone} {...fieldProps} />;
)


-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_


export const Phone = props => {
  console.log(props.dispatch) // undefined
  // ^^^^^^^^ dispatch is being stripped from props passed into <Field />

  return (
      <input
        {...props.input}
        type="tel"
        name="tel" />
  );
};

How I had to fix it:

  const fieldProps = {
    reduxDispatch: dispatch,
   //  ^^^^^ renaming dispatch to something else so it doesn`t get stripped
    ...
  };
@brotzky brotzky changed the title [6.0.0-rc.5] Unexpected behaviour when passing props to <Field /> [6.0.0-rc.5] Unexpected behaviour when passing dispatch as prop to <Field /> Aug 18, 2016
@erikras
Copy link
Member

erikras commented Aug 18, 2016

Ha! Yeah, I guess Field should just go ahead and pass dispatch to all of its components. Might as well.

@erikras
Copy link
Member

erikras commented Aug 19, 2016

Closing this. Addressed by #1569. You can use your workaround for now.

@erikras erikras closed this as completed Aug 19, 2016
@brotzky
Copy link
Author

brotzky commented Aug 20, 2016

Thanks @erikras, ended up going back to rc4 :) thanks for the updates.

@erikras
Copy link
Member

erikras commented Aug 25, 2016

Published in v6.0.1.

@lock
Copy link

lock bot commented Jun 2, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants