Skip to content

Commit 072c4f9

Browse files
author
Bhanu Teja P
committed
Setup Nextjs project with Redux
0 parents  commit 072c4f9

File tree

14 files changed

+5972
-0
lines changed

14 files changed

+5972
-0
lines changed

.gitignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
.env*
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
.idea

components/counter.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import React from 'react';
2+
import { incrementByValue, decrementByValue } from '../redux/actions/counter';
3+
import { useDispatch, useSelector } from 'react-redux';
4+
5+
const counterSelector = state => state.counter;
6+
7+
const useCounter = () => {
8+
const dispatch = useDispatch();
9+
const incrementBy10 = () => {
10+
dispatch(incrementByValue(10));
11+
}
12+
const decrementBy10 = () => {
13+
dispatch(decrementByValue(10));
14+
}
15+
return { incrementBy10, decrementBy10 };
16+
}
17+
18+
const Counter = ({}) => {
19+
const { count } = useSelector(counterSelector);
20+
const { incrementBy10, decrementBy10 } = useCounter();
21+
22+
return (
23+
<div>
24+
<span>{ count }</span>
25+
<button onClick={incrementBy10}>+10</button>
26+
<button onClick={decrementBy10}>-10</button>
27+
</div>
28+
);
29+
30+
}
31+
export default Counter;

0 commit comments

Comments
 (0)