-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
78 lines (74 loc) · 1.89 KB
/
index.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
67
68
69
70
71
72
73
74
75
/**
* Created by slashhuang on 16/5/9.
* mini react-redux
*/
import { createStore } from 'redux';
import React,{Component,PropTypes} from "react";
import {Provider,connect} from "react-redux";
import {render} from "react-dom";
let test={a:{
b:1,
c:2
}};
let {c,b}=test.a;
console.log(c,b)
var reducer=function(state,action){
return Object.assign({},state,action);
};
var action=function(){
return {
'type':'dispatching',
'data':['mini','react','redux','worked']
}
};
let store = createStore(reducer,{"hello":"world"});
class Container extends Component{
constructor(props){
super(props);
this.state={
a:0
}
}
clickDom(){
this.props.action1();
}
render(){
console.log('render', this.state.a)
return(
<div>
this is myCustomized Props { this.props.my }
<div onClick={()=>this.clickDom()}>测试react1管理的事件</div>
<ul>{this.props.data.length?'结果':''}
{this.props.data.map((ele)=>{
return <li key={ele}>{ele}</li>
})}</ul>
{this.state.a}
</div>
)
}
};
debugger;
let IndexContainer= connect((state, props)=>{
return {
data:state.data||[],
hint:state.type,
hello: props.hello
};
},(dispatch, props)=>{
return {
action1:() => dispatch(action())
}
},(stateProps, dispatchProps, parentProps) => {
return Object.assign({},stateProps, dispatchProps, parentProps, {my: "myProps"})
})(Container);
class ModuleContainer extends Component{
constructor(props){
super(props);
}
render(){
return (<Provider store={store}>
<IndexContainer hello={'world'}/>
</Provider>)
}
}
render(<ModuleContainer/>,document.getElementById('root'));