-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Re-render on element removal #464
Comments
having the same issue. this happens anytime the data is changed. |
having the same issue |
same here, data change of any single item will cause all items re-render, this behavior will cause serious performance issue. |
🤖 Hello @RaoulBivolaru! 👋 I'm Dosu, a friendly bot here to lend a hand with your issues and questions, and guide you through the path of becoming a contributor if you're keen! While we wait for a human maintainer, feel free to ask me anything. 😊 Based on the code you've provided, it seems like the carousel is re-rendering because the To prevent this, you can use a property of each item that is unique and stable as the key. For example, if each item has a unique return (
<>
{
data.map((item, index) => {
const realIndex = computedRealIndexWithAutoFillData({
index,
dataLength: rawDataLength,
loop,
autoFillData,
});
const { negativeRange, positiveRange } = displayedItems;
const shouldRender = (index >= negativeRange[0] && index <= negativeRange[1])
|| (index >= positiveRange[0] && index <= positiveRange[1]);
if (!shouldRender)
return null;
return (
<BaseLayout
key={item.userId} // Use item.userId as the key
index={index}
handlerOffset={offsetX}
visibleRanges={visibleRanges}
animationStyle={customAnimation || layoutConfig}
>
{({ animationValue }) =>
renderItem({
item,
index: realIndex,
animationValue,
})
}
</BaseLayout>
);
})
}
</>
); This assumes that each item in the data array has a unique You can find more information about this in the ItemRenderer.tsx file in the repository. Please let me know if this helps or if you have any other questions. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Describe the bug
I'm using the 'vertical-stack' mode but I'm assuming this behaviour is for all modes.
I have a list of elements in the carousel and when I remove one element from the state, the carousel is getting re-render.
Is it possible somehow to remove an item and keep the current state of carousel as it is?
To Reproduce
RPReplay_Final1692970170.mov
Expected behaviour
Carousel should not re-render when removing an item from the data object.
Code
Versions (please complete the following information):
Smartphone (please complete the following information):
The text was updated successfully, but these errors were encountered: