5a5e6004d7
Related to [11014](https://github.com/zeit/next.js/issues/11014) First and most important, removed the getInitialProps and used getStaticProps. Then, I refactored Counter, DataList and Examples components. I have refactored them from class-based components to functional. Also in each component the redux implementation was refactored using the new hooks API, which resulted in ~40% less code. If you want me to change anything or you are not satisfied with any given change, I'm open to suggestions.
20 lines
567 B
JavaScript
20 lines
567 B
JavaScript
import { useSelector, useDispatch } from 'react-redux'
|
|
import { incrementCount, decrementCount, resetCount } from '../store'
|
|
|
|
const Counter = () => {
|
|
const counter = useSelector((state) => state.count)
|
|
const dispatch = useDispatch()
|
|
|
|
return (
|
|
<div>
|
|
<h1>
|
|
Count: <span>{counter}</span>
|
|
</h1>
|
|
<button onClick={() => dispatch(incrementCount())}>+1</button>
|
|
<button onClick={() => dispatch(decrementCount())}>-1</button>
|
|
<button onClick={() => dispatch(resetCount())}>Reset</button>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default Counter
|