redux-form-material-ui icon indicating copy to clipboard operation
redux-form-material-ui copied to clipboard

Warning: Failed prop type: Invalid prop `value` of type `string` supplied to `TimePicker`, expected `object`.

Open shizhiqian opened this issue 7 years ago • 4 comments

How to set a defaultTime? import {TimePicker}from 'redux-form-material-ui'

<Field name="beginTime" component={TimePicker} />

shizhiqian avatar Jun 02 '17 02:06 shizhiqian

I get the same warning using DatePicker as well

<Field name='name' component={DatePicker} floatingLabelText='ETA' container='inline' disableYearSelection autoOk />

lsping8 avatar Jun 08 '17 07:06 lsping8

+1 Also getting the same.

kvindascr avatar Aug 21 '17 18:08 kvindascr

I've used a similar format workaround as mentioned here: https://github.com/erikras/redux-form-material-ui/issues/69#issuecomment-263950534

<Field name="name" component={DatePicker} format={(value, name) => value || null} />

Is this a confirmed bug or bad usage?

ricobl avatar Aug 29 '17 13:08 ricobl

import React from 'react';
import moment from 'moment';
import TimePicker from 'material-ui/TimePicker';


const MUITimePicker  = ({ input, defaultValue, meta: { touched, error },  ...other }) => (
    <TimePicker 
        errorText = {touched && error} 
        {...input}
        container="inline"
        mode="landscape"
        value = {input.value != '' ? moment(moment().format('DD MMM YYYY')+' '+input.value).toDate() : null}
        autoComplete="off"  
        onChange = {(event, value) => {input.onChange(moment(value).format('h:mm a'))}} 
        {...other}
        />
)
export default MUITimePicker;

To use

<Field
                    name="timepicker"
                    component={MUITimePicker}
                    floatingLabelText="Time Picker"
                    autoComplete="off"
                    autoCorrect="off"
                    autoCapitalize="off"
                    spellCheck="false"
                    type="text"/>

qalqi avatar Mar 25 '18 16:03 qalqi