Isla
Isla

Reputation: 2462

material-ui components | datePicker | no data passed to onChange

I have a simple form with a material-ui DatePicker, e.g:

<DatePicker name="startDate" autoOk={true} floatingLabelText="startDate" onChange={(x, event) => {console.log(arguments);}} />

However, if I change the date, an empty array is printed to the console. I would appreciate any suggestions on how to solve this.

"material-ui": "0.15.0"
"react": "15.1.0"
"react-tap-event-plugin": "1.0.0"
"redux": "3.0.5"
"redux-form": "^6.0.0-alpha.4"

Upvotes: 3

Views: 8689

Answers (1)

Antonis Zisis
Antonis Zisis

Reputation: 2049

What is "arguments" that you are passing in console.log() ?

From the Date Picker documentation in material-ui:

Signature: function(null: undefined, date: object) => void null: Since there is no particular event associated with the change, the first argument will always be null. date: The new date.

Therefore your code becomes:

onChange={(event, x) => {console.log(x);}}

where x is the date.

Hope it helps.

Upvotes: 6

Related Questions