Open sanonz opened 3 years ago
aaa
reducer 函数使用对象深合并,使用起来更加丝滑,希望可以加个好友!
定义:
import merge from 'lodash.merge'
const reducer = (state, data) => {
return { ...merge(state, data) }
}
更新:
dispatch({
count: state.count + 1,
account: {
displayName: account.username,
email: account.email,
},
})
https://sanonz.github.io/2020/state-management-and-performance-optimization-for-react-context-api-with-hooks/