[Browser] Virtualized swipeable views unmount and remounts all children on each swipe
See original GitHub issueWhen trying the example on the readme, I noticed that at each swipe all views with an index in range for being rendered were unmounted and remounted. I would only expect the last view to be mounted and the first one to be unmounted. All other should at most be updated.
Here is a slighly modified example that logs component mounting and unmounting. And below is the output I get as I swipe from index number 4 to index number 5.
import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import SwipeableViews from 'react-swipeable-views';
import {virtualize} from 'react-swipeable-views-utils';
const VirtualizeSwipeableViews = virtualize(SwipeableViews);
class Slide extends Component {
componentDidMount() {
console.log(this.props.index, 'did mount');
}
componentWillUnmount() {
console.log(this.props.index, 'will unmount');
}
render() {
const index = this.props.index;
return <div>{`slide n°${index}`}</div>;
}
}
const slideRenderer = ({key, index}) => {
return (
<Slide key={key} index={index} />
);
};
const node = document.getElementById('app');
const root = <VirtualizeSwipeableViews slideRenderer={slideRenderer} />;
ReactDOM.render(root, node);
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top Results From Across the Web
Usage - react-swipeable-views
Usage. Get started with react-swipeable-views in no time. Simple example. usage. Browser. import React from 'react'; import SwipeableViews from ...
Read more >How to use the react-swipeable-views-utils.virtualize function ...
To help you get started, we've selected a few react-swipeable-views-utils examples, based on popular ways it is used in public projects.
Read more >Avoid unnecessary remounting of DOM elements in React
I ran into a strange problem while trying to use React's built-in animation API to fade in/out DOM elements when they enter/exit the...
Read more >React Autocomplete/Dropdown/Select Components – downshift
The plan is to create each hook in that repo, test it against Downshift ... be the cool kid from the future that...
Read more >Untitled
Find a one-night stand or a hookup you can also hang out with. Which dating site is best for serious relationships? What is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Oh, right! I’m so sorry! I get it now. Thanks so much for your patience.
@bmueller-sykes Yes, It’s. We prerender the slides forward and backward.