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
Show 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 {
...
@@ -14,10 +14,15 @@ export default {
salesTypeDataOnline
:
[],
salesTypeDataOnline
:
[],
salesTypeDataOffline
:
[],
salesTypeDataOffline
:
[],
radarData
:
[],
radarData
:
[],
loading
:
false
,
},
},
effects
:
{
effects
:
{
*
fetch
(
_
,
{
call
,
put
})
{
*
fetch
(
_
,
{
call
,
put
})
{
yield
put
({
type
:
'
changeLoading
'
,
payload
:
true
,
});
const
response
=
yield
call
(
fakeChartData
);
const
response
=
yield
call
(
fakeChartData
);
yield
put
({
yield
put
({
type
:
'
save
'
,
type
:
'
save
'
,
...
@@ -40,12 +45,7 @@ export default {
...
@@ -40,12 +45,7 @@ export default {
return
{
return
{
...
state
,
...
state
,
...
payload
,
...
payload
,
};
loading
:
false
,
},
setter
(
state
,
{
payload
})
{
return
{
...
state
,
...
payload
,
};
};
},
},
clear
()
{
clear
()
{
...
@@ -62,5 +62,11 @@ export default {
...
@@ -62,5 +62,11 @@ export default {
radarData
:
[],
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) {
...
@@ -27,7 +27,6 @@ for (let i = 0; i < 7; i += 1) {
}))
}))
export
default
class
Analysis
extends
Component
{
export
default
class
Analysis
extends
Component
{
state
=
{
state
=
{
loading
:
true
,
salesType
:
'
all
'
,
salesType
:
'
all
'
,
currentTabKey
:
''
,
currentTabKey
:
''
,
rangePickerValue
:
[],
rangePickerValue
:
[],
...
@@ -36,7 +35,7 @@ export default class Analysis extends Component {
...
@@ -36,7 +35,7 @@ export default class Analysis extends Component {
componentDidMount
()
{
componentDidMount
()
{
this
.
props
.
dispatch
({
this
.
props
.
dispatch
({
type
:
'
chart/fetch
'
,
type
:
'
chart/fetch
'
,
})
.
then
(()
=>
this
.
setState
({
loading
:
false
}))
;
});
}
}
componentWillUnmount
()
{
componentWillUnmount
()
{
...
@@ -90,7 +89,7 @@ export default class Analysis extends Component {
...
@@ -90,7 +89,7 @@ export default class Analysis extends Component {
}
}
render
()
{
render
()
{
const
{
rangePickerValue
,
salesType
,
currentTabKey
,
loading
}
=
this
.
state
;
const
{
rangePickerValue
,
salesType
,
currentTabKey
}
=
this
.
state
;
const
{
chart
}
=
this
.
props
;
const
{
chart
}
=
this
.
props
;
const
{
const
{
visitData
,
visitData
,
...
@@ -102,6 +101,7 @@ export default class Analysis extends Component {
...
@@ -102,6 +101,7 @@ export default class Analysis extends Component {
salesTypeData
,
salesTypeData
,
salesTypeDataOnline
,
salesTypeDataOnline
,
salesTypeDataOffline
,
salesTypeDataOffline
,
loading
,
}
=
chart
;
}
=
chart
;
const
salesPieData
=
salesType
===
'
all
'
?
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