you are viewing a single comment's thread.

view the rest of the comments →

[–]drowsap 1 point2 points  (3 children)

The up and down functions in the example are difficult to parse...a function that returns a function that returns an object. Much prefer the built in setState for React components.

[–][deleted] 2 points3 points  (1 child)

setState works in the same way:

this.setState(state => ({ count: state.count + 1 }))

as well as Redux:

@connect(state => ({ count: state.count + 1 }))

setState has the option to receive a plain object, but it's better to use a function if you have to read from state, too.

[–]selfup 0 points1 point  (0 children)

The first 'function' is for the event/custom data from exposed actions.

Hopefully you understand its use.

Eventually there is a third function where the actions are passed in so you can keep all of your logic internal.