diff --git a/helloworld-redux-counter/package.json b/helloworld-redux-counter/package.json index fc4401c..5df20da 100644 --- a/helloworld-redux-counter/package.json +++ b/helloworld-redux-counter/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "immutable": "^4.0.0-rc.12", + "moment": "^2.22.2", "react": "^16.5.1", "react-dom": "^16.5.1", "react-redux": "^5.0.7", diff --git a/helloworld-redux-counter/src/containers/HelloWorld.js b/helloworld-redux-counter/src/containers/HelloWorld.js index 16e59f5..29c3191 100644 --- a/helloworld-redux-counter/src/containers/HelloWorld.js +++ b/helloworld-redux-counter/src/containers/HelloWorld.js @@ -1,15 +1,18 @@ import { connect } from 'react-redux'; -import { incrementCount } from '../actions/counter.js'; import HelloWorld from '../components/HelloWorld' -export const mapStateToProps = (state) => ({ - clicks: state.get('counter') || 0 -}); +import * as moment from 'moment'; -export const mapDispatchToProps = dispatch => ({ - incrementClick: ()=>dispatch(incrementCount()) -}) + +export const mapStateToProps = (state) => { + let daysUntilBirthday = moment + .duration(moment('2020-01-01') + .diff(moment())) + .days() + return { + message: `${state.get('message')} - You have ${daysUntilBirthday} days until your birthday!` + } +} export default connect( mapStateToProps, - mapDispatchToProps, )(HelloWorld); \ No newline at end of file diff --git a/helloworld-redux-counter/yarn.lock b/helloworld-redux-counter/yarn.lock index 4c798e1..a018de9 100644 --- a/helloworld-redux-counter/yarn.lock +++ b/helloworld-redux-counter/yarn.lock @@ -4450,6 +4450,11 @@ mkdirp@0.5.1, mkdirp@0.5.x, mkdirp@^0.5.0, mkdirp@^0.5.1, mkdirp@~0.5.0, mkdirp@ dependencies: minimist "0.0.8" +moment@^2.22.2: + version "2.22.2" + resolved "https://registry.yarnpkg.com/moment/-/moment-2.22.2.tgz#3c257f9839fc0e93ff53149632239eb90783ff66" + integrity sha1-PCV/mDn8DpP/UxSWMiOeuQeD/2Y= + ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"