diff --git a/package.json b/package.json index d54e0a079..f07d94dab 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ }, "dependencies": { "prop-types": "^15.7.2", - "react": "^16.8.0", + "react": "^16.8.6", "react-dom": "^16.8.0", "react-redux": "^7.1.0", "redux": "^4.0.1" @@ -19,5 +19,17 @@ "build": "react-scripts build", "eject": "react-scripts eject", "test": "react-scripts test" + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] } } diff --git a/src/actions/index.js b/src/actions/index.js index 17cab299b..b175f2b5b 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -11,8 +11,16 @@ export const DECREMENT = 'DECREMENT'; export const increment = () => { // Fill in this function + return { + type: INCREMENT, + payload: 1 + }; }; export const decrement = () => { // Fill in this function -}; + return { + type: DECREMENT, + payload: -1 + }; +}; \ No newline at end of file diff --git a/src/components/Counter.js b/src/components/Counter.js index 85802fbde..0132d5b61 100644 --- a/src/components/Counter.js +++ b/src/components/Counter.js @@ -1,4 +1,4 @@ -import React, { Component } from "react"; + import React, { Component } from "react"; import { connect } from 'react-redux'; import { increment, decrement } from '../actions'; @@ -20,10 +20,10 @@ class Counter extends Component { return (

Clicked: {this.props.count} times - - {/* Uncomment these button tags if you got diff --git a/src/index.js b/src/index.js index 99dee4df4..393bcaca5 100644 --- a/src/index.js +++ b/src/index.js @@ -18,8 +18,8 @@ const store = createStore(counter); // is passing its state to. The Provider component is also // where the store "lives". ReactDOM.render( - - - , - document.getElementById('root') + + + , + document.getElementById('root') ); diff --git a/src/reducers/index.js b/src/reducers/index.js index 9c9ce946e..dc9d677a7 100644 --- a/src/reducers/index.js +++ b/src/reducers/index.js @@ -1,8 +1,8 @@ import { INCREMENT, DECREMENT } from '../actions'; const initialState = { - count: 0 -} + count: 0 +}; // Our reducer that handles our two action cases: // increment and decrement. It receives the state @@ -10,12 +10,18 @@ const initialState = { // by our action creator. What does the reducer // need to do with the count in each case? export default (state = initialState, action) => { - switch (action.type) { - case INCREMENT: - // Fill in the body of this case - case DECREMENT: - // Fill in the body of this case - default: - return state; - } + switch (action.type) { + case INCREMENT: + // Fill in the body of this case + return { + count: state.count + action.payload + }; + case DECREMENT: + // Fill in the body of this case + return { + count: state.count + action.payload + }; + default: + return state; + } }; diff --git a/yarn.lock b/yarn.lock index b67767972..9c1d007c2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8131,7 +8131,7 @@ react-test-renderer@^16.8.6: react-is "^16.8.6" scheduler "^0.13.6" -react@^16.8.0: +react@^16.8.6: version "16.8.6" resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe" integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw==