Is @ connect a grammatical sugar in react-redux? How to use it?

currently only know the traditional usage

const App = connect(
    mapStateToProps,
    mapDispatchToProps
)(Counter);

but many projects use

@connect(state => ({
  value: state.global.value,
  extinfo: state.extinfo,
}))

I can understand what it means, but do I still want to get a more comprehensive understanding of how this grammar is used?

Mar.02,2021

https://www.tslang.cn/docs/ha.


you'd better honestly use the first one.
although the second can be parsed through babel . But none of the Ecma standards has been officially released.

unless you convert all kinds of babel , the compatibility of various browsers is in the palm of your hand.


react-redux is too troublesome to write. It is recommended that you use react-mobx, to make it easy to use


react-redux is too troublesome to write, and it is recommended that you use react-mobx, to make it easy to use


this is decorator mode.
first install babel-plugin-transform-decorators-legacy,
and then in .babelrc

"plugins": ["transform-decorators-legacy"]

is fine

Menu