I can’t understand the kea code (a redux alternative)

I can’t understand the kea code (a redux alternative)

Hi guys, first and foremost, I've a JS experience but I'm not totally familiarized with all the new JS syntax, recently I found this post


I really can't understand this code

actions: () => ({ increment: (amount) => ({ amount }), decrement: (amount) => ({ amount }) }),

is it basically an object with two keys which have has value two functions, these functions take some value and….. what happen here { amount }

the other part is also confusing

reducers: ({ actions }) => ({ counter: [0, PropTypes.number, { [actions.increment]: (state, payload) => state + payload.amount, [actions.decrement]: (state, payload) => state – payload.amount }] }) })

what means

[actions.increment]: (state, payload) => state + payload.amount

is an array has key??…what is this useful?…

I don't know but all these syntax sugar is a bit confusing for me…thanks guy…hope you can help me

Submitted August 11, 2017 at 06:25AM by lalolambda3141592
via reddit http://ift.tt/2hPAgZd


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s