This file contains 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
Show hidden characters
{ | |
"compilerOptions": { | |
"target": "es5", | |
"lib": [ | |
"dom", | |
"dom.iterable", | |
"esnext" | |
], | |
"allowJs": true, | |
"skipLibCheck": true, |
This file contains 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 { createSlice, PayloadAction } from '@reduxjs/toolkit'; | |
type CurrentDisplayState = { | |
clicks: number | |
} | |
let initialState: CurrentDisplayState = { | |
clicks: 0, | |
} |
This file contains 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 { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit' | |
import createSagaMiddleware from 'redux-saga'; | |
import { createInjectorsEnhancer } from 'redux-injectors'; | |
import createReducer from './rootReducer' | |
import rootSaga from './sagas' | |
export default function configureAppStore(initialState = {}) { | |
const reduxSagaMonitorOptions = {}; | |
const sagaMiddleware = createSagaMiddleware(reduxSagaMonitorOptions); |
This file contains 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 { combineReducers } from '@reduxjs/toolkit' | |
import clicksReducer from './counter' | |
const clicks = { count: clicksReducer } | |
export let rootReducer = combineReducers({ | |
...clicks | |
}) |
This file contains 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 { all, call, delay, put, takeEvery } from 'redux-saga/effects' | |
import { addCount } from '../counter'; | |
export function* incrementAsync() { | |
yield delay(1000) | |
yield put(addCount(1)) | |
} | |
export function* watchIncrementAsync() { | |
yield takeEvery('INCREMENT_ASYNC', incrementAsync) |
This file contains 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 React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { Provider } from 'react-redux'; | |
import './index.css'; | |
import configureStore from './store' | |
import App from './App'; | |
import * as serviceWorker from './serviceWorker'; | |
const initialState = {}; | |
const store = configureStore(initialState); |
This file contains 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 React from 'react'; | |
import './App.css'; | |
interface ICounterProps { | |
value?: number; | |
onIncrement?: any; | |
onDecrement?: any; | |
onIncrementAsync?: any; | |
} | |
const Counter: React.FC<ICounterProps> = |
This file contains 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 React from 'react'; | |
import { useSelector, useDispatch } from 'react-redux'; | |
import { RootState } from './rootReducer'; | |
import logo from './logo.svg'; | |
import Counter from './Counter'; | |
import { addCount, minusCount } from './counter'; | |
import './App.css'; | |
export const incrementAsync = () => ({ | |
type: 'INCREMENT_ASYNC', |
This file contains 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
{ | |
"package": { | |
"dependencies": { | |
"@reduxjs/toolkit": "^1.4.0", | |
"@types/node": "^12.0.0", | |
"@types/react": "^16.9.0", | |
"@types/react-dom": "^16.9.0", | |
"@types/react-redux": "^7.1.9", | |
"react-redux": "^7.2.0", | |
"redux": "^4.0.5", |
This file contains 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 { combineReducers } from '@reduxjs/toolkit' | |
import clicksReducer from './counter' | |
const clicks = { count: clicksReducer } | |
export let rootReducer = combineReducers({ | |
...clicks | |
}) |