React Box
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.
Installation
npm install react-box
Usage
Wrap your content into Box
element, and make sure that children of different classes have distinct keys:
{ var content; if thispropsmode === 'map' content = <Map ='map' />; else content = <Post ='post' = /> return <Box> content </Box>;}
This example will result in the following HTML structure:
<!-- Initial render: <Content mode='map' /> --> <!-- … --> <!-- First update: <Content mode='post' id='1' /> --> <!-- … --> Post ID: 1 <!-- … --> <!-- Second update: <Content mode='post' id='2' /> --> <!-- … --> Post ID: 1 <!-- … --> Post ID: 2 <!-- … --> <!-- Third update: <Content mode='post' id='2' /> --> <!-- … --> Post ID: 1 <!-- … --> Post ID: 2 <!-- … -->