Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Wraps repeatedly rerendered components preserving their nodes in real DOM to reduce paints
Wraps repeatedly rerendered components preserving their nodes in real DOM to reduce paints. The idea is borrowed from Noscript framework, where box is a container for views that manages visibility of active views instead of taking irrelevant nodes out of DOM.
npm install react-box
Wrap your content into Box
element, and make sure that children of different classes have distinct keys:
render: function() {
var content;
if (this.props.mode === 'map') {
content = <Map key='map' />;
} else {
content = <Post key='post' id={ this.props.id } />
}
return <Box>{ content }</Box>;
}
This example will result in the following HTML structure:
<!-- Initial render: <Content mode='map' /> -->
<div>
<div style="display: block;">
<div class="map"><!-- … --></div>
</div>
</div>
<!-- First update: <Content mode='post' id='1' /> -->
<div>
<div style="display: none;">
<div class="map"><!-- … --></div>
</div>
<div style="display: block;">
<div class="post">
<h1>Post ID: 1</h1>
<!-- … -->
</div>
</div>
</div>
<!-- Second update: <Content mode='post' id='2' /> -->
<div>
<div style="display: none;">
<div class="map"><!-- … --></div>
</div>
<div style="display: none;">
<div class="post">
<h1>Post ID: 1</h1>
<!-- … -->
</div>
</div>
<div style="display: block;">
<div class="post">
<h1>Post ID: 2</h1>
<!-- … -->
</div>
</div>
</div>
<!-- Third update: <Content mode='post' id='2' /> -->
<div>
<div style="display: block;">
<div class="map"><!-- … --></div>
</div>
<div style="display: none;">
<div class="post">
<h1>Post ID: 1</h1>
<!-- … -->
</div>
</div>
<div style="display: none;">
<div class="post">
<h1>Post ID: 2</h1>
<!-- … -->
</div>
</div>
</div>
FAQs
Wraps repeatedly rerendered components preserving their nodes in real DOM to reduce paints
We found that react-box demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.