DEV Community

Discussion on: CerebralJS

Collapse
 
batmansmk profile image
Bat Manson

The verbosity of the Redux connect example can be reduced by using the official API and some JS syntax:

import { connect } from 'react-redux'
import { increase, decrease } from './actions'

/** same component here **/

export default connect(
  state => ({count:state}),
  {decrease, increase}
)(Counter)

Enter fullscreen mode Exit fullscreen mode

No need to create mapDispatchToProps intermediate functions. It is less verbose than cerebraljs :).

It has an edge over the presented Cerebral equivalent as it uses the correct JS references instead of some some template string + string references which removes typings, linter features, autocomplete, IDE functions etc.

If you want to be fair, you also have to add propTypes in both examples, not only in the redux examples.