forked from mingsterism/react-redux-counter1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reduxCounter1.js
66 lines (51 loc) · 1.35 KB
/
reduxCounter1.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import React, { Component } from 'react';
import { createStore } from 'redux';
import Reducer1 from '../reducers/counterReducer1';
import { compose, withState, withHandlers } from 'recompose';
const store = createStore(Reducer1)
const GetReduxState = () => {
const reduxButton = compose(
withState('rState', 'getRState', { name: "james" }),
withHandlers({
getStateRedux: (props) => () => props.getRState( (s) => console.log('!!!: ', s))
})
)
const RunFunction = () => {
console.log(" reduxCounter1.js : Initial State: ", store.getState())
store.dispatch({
type: "INCREMENT",
payload: 10
})
console.log(" reduxCounter1.js : Store after dispatch: ", store.getState())
}
const getReduxState = () => {
console.log(store.getState())
}
const normalButton = reduxButton(({ getRState }) => {
console.log("normal button being invoked")
return (
<div>
<button onClick={getRState}> HOC</button>
</div>
)
})
const normalButton1 = () => {
return (
<div>
<h3> Button works </h3>
</div>
)
}
return (
<div>
{RunFunction()}
<button onClick={getReduxState}> GET THE STATE </button>
{normalButton1()}
<normalButton />
{
// why is normalButton not invoking?
}
</div>
)
}
export default GetReduxState;