Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
ant-design-pro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
duanledexianxianxian
ant-design-pro
Commits
1e315ca3
Commit
1e315ca3
authored
Dec 11, 2017
by
afc163
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix setState on unmounted component, close #338
parent
753dc958
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
src/models/chart.js
src/models/chart.js
+12
-6
src/routes/Dashboard/Analysis.js
src/routes/Dashboard/Analysis.js
+3
-3
No files found.
src/models/chart.js
View file @
1e315ca3
...
...
@@ -14,10 +14,15 @@ export default {
salesTypeDataOnline
:
[],
salesTypeDataOffline
:
[],
radarData
:
[],
loading
:
false
,
},
effects
:
{
*
fetch
(
_
,
{
call
,
put
})
{
yield
put
({
type
:
'
changeLoading
'
,
payload
:
true
,
});
const
response
=
yield
call
(
fakeChartData
);
yield
put
({
type
:
'
save
'
,
...
...
@@ -40,12 +45,7 @@ export default {
return
{
...
state
,
...
payload
,
};
},
setter
(
state
,
{
payload
})
{
return
{
...
state
,
...
payload
,
loading
:
false
,
};
},
clear
()
{
...
...
@@ -62,5 +62,11 @@ export default {
radarData
:
[],
};
},
changeLoading
(
state
,
{
payload
})
{
return
{
...
state
,
loading
:
payload
,
};
},
},
};
src/routes/Dashboard/Analysis.js
View file @
1e315ca3
...
...
@@ -27,7 +27,6 @@ for (let i = 0; i < 7; i += 1) {
}))
export
default
class
Analysis
extends
Component
{
state
=
{
loading
:
true
,
salesType
:
'
all
'
,
currentTabKey
:
''
,
rangePickerValue
:
[],
...
...
@@ -36,7 +35,7 @@ export default class Analysis extends Component {
componentDidMount
()
{
this
.
props
.
dispatch
({
type
:
'
chart/fetch
'
,
})
.
then
(()
=>
this
.
setState
({
loading
:
false
}))
;
});
}
componentWillUnmount
()
{
...
...
@@ -90,7 +89,7 @@ export default class Analysis extends Component {
}
render
()
{
const
{
rangePickerValue
,
salesType
,
currentTabKey
,
loading
}
=
this
.
state
;
const
{
rangePickerValue
,
salesType
,
currentTabKey
}
=
this
.
state
;
const
{
chart
}
=
this
.
props
;
const
{
visitData
,
...
...
@@ -102,6 +101,7 @@ export default class Analysis extends Component {
salesTypeData
,
salesTypeDataOnline
,
salesTypeDataOffline
,
loading
,
}
=
chart
;
const
salesPieData
=
salesType
===
'
all
'
?
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment