Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
A
app-manage-console
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
ReactNative
app-manage-console
Commits
a5da6143
提交
a5da6143
authored
6月 20, 2018
作者:
vipcxj
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
避免组件频繁unmount和mount
上级
f97da3cf
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
26 行删除
+24
-26
stateful.js
src/components/hoc/stateful.js
+22
-25
index.js
src/components/table/dstable/index.js
+2
-1
没有找到文件。
src/components/hoc/stateful.js
浏览文件 @
a5da6143
...
...
@@ -15,33 +15,19 @@ const connect = (modelCreator, { app, mapStateToProps, mapDispatchToProps, merge
const
{
name
,
model
}
=
modelCreator
();
this
.
name
=
name
;
this
.
model
=
model
;
}
componentWillMount
()
{
(
app
||
this
.
props
.
app
||
getApp
()).
model
(
this
.
model
);
}
componentWillUnmount
()
{
(
app
||
this
.
props
.
app
||
getApp
()).
unmodel
(
this
.
model
.
namespace
);
}
render
()
{
const
{
children
,
...
rest
}
=
this
.
props
;
const
name
=
this
.
name
;
const
model
=
this
.
model
;
const
mapState
=
(
state
)
=>
{
const
p
ro
ps
=
mapStateToProps
?
mapStateToProps
(
state
)
:
{};
p
ro
ps
[
name
]
=
state
[
model
.
namespace
];
p
ro
ps
[
namespaceVar
||
'namespace'
]
=
model
.
namespace
;
const
pps
=
mapStateToProps
?
mapStateToProps
(
state
)
:
{};
pps
[
name
]
=
state
[
model
.
namespace
];
pps
[
namespaceVar
||
'namespace'
]
=
model
.
namespace
;
if
(
state
.
loading
)
{
p
ro
ps
.
loading
=
state
.
loading
;
p
rops
.
loading
.
model
=
pro
ps
.
loading
.
models
[
model
.
namespace
];
p
ro
ps
.
loading
.
effect
=
flow
(
pps
.
loading
=
state
.
loading
;
p
ps
.
loading
.
model
=
p
ps
.
loading
.
models
[
model
.
namespace
];
pps
.
loading
.
effect
=
flow
(
pickBy
((
v
,
k
)
=>
startsWith
(
`
${
model
.
namespace
}
/`
,
k
)),
mapKeys
(
k
=>
k
.
slice
(
model
.
namespace
.
length
+
1
)),
)(
p
ro
ps
.
loading
.
effects
);
)(
pps
.
loading
.
effects
);
}
return
p
ro
ps
;
return
pps
;
};
const
mapDispatch
=
(
dispatch
)
=>
{
const
extras
=
mapDispatchToProps
?
mapDispatchToProps
(
dispatch
)
:
{};
...
...
@@ -54,11 +40,22 @@ const connect = (modelCreator, { app, mapStateToProps, mapDispatchToProps, merge
},
};
};
const
Output
=
dvaConnect
(
mapState
,
mapDispatch
,
mergeProps
,
options
)(
Comp
);
this
.
Output
=
dvaConnect
(
mapState
,
mapDispatch
,
mergeProps
,
options
)(
Comp
);
}
componentWillMount
()
{
(
app
||
this
.
props
.
app
||
getApp
()).
model
(
this
.
model
);
}
componentWillUnmount
()
{
(
app
||
this
.
props
.
app
||
getApp
()).
unmodel
(
this
.
model
.
namespace
);
}
render
()
{
const
{
children
,
...
rest
}
=
this
.
props
;
return
(
<
Output
{...
rest
}
>
<
this
.
Output
{...
rest
}
>
{
children
}
<
/Output
>
<
/
this.
Output
>
);
}
...
...
src/components/table/dstable/index.js
浏览文件 @
a5da6143
...
...
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import
modelCreator
from
'./model'
;
import
connect
from
'../../hoc/stateful'
;
import
TableEx
from
'../../../components/table/index'
;
import
{
shallowEqual
}
from
'../../../utils/helper'
;
import
styles
from
'./index.less'
;
class
DsTable
extends
React
.
Component
{
...
...
@@ -14,7 +15,7 @@ class DsTable extends React.Component {
componentWillReceiveProps
(
nextProps
)
{
const
{
coordinate
,
params
}
=
nextProps
;
const
{
dispatchLocal
}
=
this
.
props
;
if
(
coordinate
!==
this
.
props
.
coordinate
||
params
!==
this
.
props
.
params
)
{
if
(
!
shallowEqual
(
coordinate
,
this
.
props
.
coordinate
)
||
!
shallowEqual
(
params
,
this
.
props
.
params
)
)
{
dispatchLocal
({
type
:
'doInit'
,
payload
:
{
coordinate
,
params
}
});
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论