xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

React & update state with props & Object.assign

React & update state with props & Object.assign

Object.assign({}, oldObj, newObj)

https://reactjs.org/docs/react-component.html#unsafe_componentwillreceiveprops


Object.assign(
  previousState,
  {quantity: state.quantity + 1},
  {quantity: state.quantity + 1},
  ...
)


https://stackoverflow.com/questions/32414308/updating-state-on-props-change-in-react-form



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


posted @ 2019-09-26 14:48  xgqfrms  阅读(169)  评论(1编辑  收藏  举报