Thanks for the invitation, actually I haven’t written react for a long time....
The signature of setState is like this setState(nextState: object | function, callback?: function) Only accepts the first parameter as nextState, and the second parameter is the callback after setState ends and is re-rendered
And your code has too many flaws Just to traverse and calculate totalPrice and totalCount, you should use _.each instead of _.map And set the props to state. What is this going to do...
The way is wrong, the second parameter of setState is a function.
I guess you want to write it like this,
But I don’t understand why I need to
props
放到state
. Is there any other operation?Where did you learn this usage of setState from?
setState
Thanks for the invitation, actually I haven’t written react for a long time....
The signature of setState is like this
setState(nextState: object | function, callback?: function)
Only accepts the first parameter as nextState, and the second parameter is the callback after setState ends and is re-rendered
And your code has too many flaws
Just to traverse and calculate totalPrice and totalCount, you should use _.each instead of _.map
And set the props to state. What is this going to do...