Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
Liquid Design React
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
4
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Liquid Design
Liquid Design React
Commits
8aea6ba5
Commit
8aea6ba5
authored
4 years ago
by
Boris Diakur
Browse files
Options
Downloads
Patches
Plain Diff
fix(icon): prevent state update on unmounted component
parent
0656b3ee
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!210
fix(icon): prevent state update on unmounted component
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/elements/Icon/index.js
+16
-7
16 additions, 7 deletions
src/elements/Icon/index.js
with
16 additions
and
7 deletions
src/elements/Icon/index.js
+
16
−
7
View file @
8aea6ba5
import
React
,
{
PureComponent
}
from
'
react
'
import
PropTypes
from
'
prop-types
'
import
styled
,
{
css
,
withTheme
}
from
'
styled-components
'
import
{
path
}
from
'
ramda
'
import
React
,
{
PureComponent
}
from
'
react
'
import
cx
from
'
classnames
'
import
iconsList
from
'
../../elements/Icon/iconsList
'
...
...
@@ -78,6 +78,7 @@ export class Icon extends PureComponent {
}
componentDidMount
()
{
this
.
_isMounted
=
true
const
{
name
,
isFilled
}
=
this
.
props
let
importPromise
...
...
@@ -102,17 +103,25 @@ export class Icon extends PureComponent {
importPromise
()
.
then
(({
default
:
DefaultExport
,
NamedExport
})
=>
{
this
.
setState
({
svgIconComponent
:
DefaultExport
,
})
if
(
this
.
_isMounted
)
{
this
.
setState
({
svgIconComponent
:
DefaultExport
,
})
}
})
.
catch
(
err
=>
{
this
.
setState
({
error
:
err
,
})
if
(
this
.
_isMounted
)
{
this
.
setState
({
error
:
err
,
})
}
})
}
componentWillUnmount
()
{
this
.
_isMounted
=
false
}
render
()
{
if
(
this
.
state
.
error
)
return
<
code
>
invalid
icon
name
<
/code
>
...
...
This diff is collapsed.
Click to expand it.
Boris Diakur
@diakur
mentioned in commit
389d2472
·
4 years ago
mentioned in commit
389d2472
mentioned in commit 389d2472e3ac01ed3017cf00605f240ec44fb259
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment