admin管理员组

文章数量:1399939

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"

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"
Share Improve this question edited Jun 8, 2016 at 14:38 marcospereira 12.2k3 gold badges48 silver badges53 bronze badges asked Jun 8, 2016 at 13:42 IslaIsla 2,4625 gold badges29 silver badges36 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

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 bees:

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

where x is the date.

Hope it helps.

本文标签: javascriptmaterialui componentsdatePickerno data passed to onChangeStack Overflow