react-native-redux-form-example icon indicating copy to clipboard operation
react-native-redux-form-example copied to clipboard

Not hitting dispatching submit function

Open The-Code-Monkey opened this issue 7 years ago • 3 comments

So i have copied your example and linked it up to an api endpoint which should error due to not being authenticated but its not seeming to get to the action.

`import { submitForm } from '../../reducers/audits';

const onSubmit = (values) => { console.warn(values); submitForm(values); }; const countryOptions = [ { label: 'Denmark', value: 'DK' }, { label: 'Germany', value: 'DE' }, { label: 'United State', value: 'US' }, ];

class Audit extends Component { render() { const { handleSubmit, submitting } = this.props;

return (
  <Form>
    <FieldsContainer>
      <Fieldset label="Contact details">
        <Input name="first_name" label="First name" placeholder="John" />
        <Input name="last_name" label="Last name" placeholder="Doe" />
        <Input name="email" label="Email" placeholder="[email protected]" />
        <Input name="telephone" label="Phone" placeholder="+45 88 88 88 88" />
      </Fieldset>
      <Fieldset label="Shipping details" last>
        <Input name="address" label="Address" placeholder="Hejrevej 33" />
        <Input name="city" label="City" placeholder="Copenhagen" />
        <Input name="zip" label="ZIP Code" placeholder="2400" />
        <Select
          name="country"
          label="Country"
          options={countryOptions}
          placeholder="Denmark"
        />
        <Switch label="Save my details" border={false} name="save_details" />
      </Fieldset>
    </FieldsContainer>
    <ActionsContainer>
      <Button icon="md-checkmark" iconPlacement="right" onPress={handleSubmit(onSubmit)} submitting={submitting}>Save</Button>
    </ActionsContainer>
  </Form>
);

} }

export default reduxForm({ form: 'Form', validate: (values) => { const errors = {};

if (!values.first_name) {
  errors.first_name = 'First name is required.';
}

if (!values.last_name) {
  errors.last_name = 'Last name is required.';
}

if (!values.email) {
  errors.email = 'Email is required.';
}

return errors;

}, })(Audit);`

this is all my code im not sure where im going wrong as that console warn will warn me with the object with my field values in it but some reason it wont hit the submitForm from my reducer.

I am new to react-native I am normally a reactjs dev

The-Code-Monkey avatar May 23 '18 08:05 The-Code-Monkey

Did you ever get a fix for this? Cos I have the same issue too.

romeo-folie avatar Aug 22 '18 07:08 romeo-folie

can you make a gist of your code and ill see if its the same issue

The-Code-Monkey avatar Aug 22 '18 07:08 The-Code-Monkey

Never mind. Turns out it wasn't the same thing and I fixed mine. Appreciate your will to help though.

romeo-folie avatar Aug 23 '18 09:08 romeo-folie