Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Rex Dri
Rex Dri
Commits
cbd26501
Commit
cbd26501
authored
Sep 14, 2018
by
Florent Chehab
Browse files
Better performance by not updating none visible elements (Visibility is stored in props)
parent
0a024877
Changes
1
Hide whitespace changes
Inline
Side-by-side
frontend/src/components/MyComponent.js
View file @
cbd26501
...
...
@@ -119,6 +119,14 @@ class MyComponent extends Component {
}
myComponentDidMount
()
{
};
shouldComponentUpdate
(
nextProps
,
nextState
)
{
if
(
typeof
this
.
nextProps
.
visible
!=
'
undefined
'
&&
!
this
.
nextProps
.
visible
)
{
// don't rerender components that are not visible.
return
false
;
}
return
true
;
}
componentDidUpdate
(
prevProps
,
prevState
,
snapshot
)
{
// TODO ajouter expire date
this
.
loadPropsIfNeeded
();
...
...
Write
Preview
Supports
Markdown
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