Created
November 5, 2018 20:11
-
-
Save ctrlplusb/51dbe544049a8d591be31ec5efedd270 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { select } from 'easy-peasy'; // ๐ import the helper | |
const store = createStore({ | |
shoppingBasket: { | |
products: [{ name: 'Shoes', price: 123 }, { name: 'Hat', price: 75 }], | |
// ๐ define your derived state | |
totalPrice: select(state => | |
state.products.reduce((acc, cur) => acc + cur.price, 0) | |
) | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment