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

Prop "format" for TimePicker component interfere with Field components prop #49

Closed
aludvigsen opened this issue Oct 14, 2016 · 4 comments

Comments

@aludvigsen
Copy link

To set the format for the TimePicker we use the format prop like this
<TimePicker format="24hr" />

How to set prop format when using the Field component?

<Field name="some_name" component={TimePicker} format="24hr" />
This is not working because the Field component already has a prop called format.

@jamieparkinson
Copy link

jamieparkinson commented Oct 26, 2016

Not an ideal solution, but you can introduce a new prop (let's say timeFormat) that gets converted to format in mapProps:

createComponent(
  TimePicker,
  ({
    input: {
      onBlur, // eslint-disable-line no-unused-vars
      onChange,
      ...inputProps
    },
    timeFormat,
    ...props
  }) => ({
    ...inputProps,
    ...mapError(props),
    format: timeFormat,
    onChange: (event, value) => onChange(value),
    value: inputProps.value !== '' ? inputProps.value : null
  })
)

Where I have also added the last line as per #37

So now you can write:

<Field name="some_name"
       component={TimePicker}
       timeFormat="24hr" />

@itditp
Copy link

itditp commented Dec 30, 2016

any news on this?

@tikitikipoo
Copy link

below code works fine

              <Field
                name="at"
                component={TimePicker}
                format={null}
                props={{format: "24hr"}}
              />

@mihirsoni
Copy link
Collaborator

Thanks @tikitikipoo For the help :) Closing this feel free to open if still facing an issue.

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

5 participants