mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-09-03 12:41:45 +02:00
fix: crash when an item was removed from Virtuouso
This was a pesky bug. Basically the `props.items.length` did not get updated which resulted in the `index` being always one greater than actual. Since `index[out-of-range]` is `undefined` in JS, the app crashed as it could not find any prop. Very pesky. Fixed it however.
This commit is contained in:
@@ -44,7 +44,11 @@ function ListContainer(props) {
|
||||
overflowX: "hidden",
|
||||
}}
|
||||
totalCount={props.items.length}
|
||||
item={(index) => props.item(index, props.items[index])}
|
||||
item={(index) => {
|
||||
const item = props.items[index];
|
||||
if (!item) return null;
|
||||
return props.item(index, item);
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
</Flex>
|
||||
|
||||
@@ -163,8 +163,6 @@ export default React.memo(Note, function (prevProps, nextProps) {
|
||||
const prevItem = prevProps.item;
|
||||
const nextItem = nextProps.item;
|
||||
|
||||
// do not update if the item was removed
|
||||
if (!prevItem || !nextItem) return true;
|
||||
return (
|
||||
prevItem.pinned === nextItem.pinned &&
|
||||
prevItem.favorite === nextItem.favorite &&
|
||||
|
||||
@@ -42,11 +42,12 @@ function Home() {
|
||||
</Box>
|
||||
);
|
||||
}}
|
||||
item={(index, groupIndex) =>
|
||||
notes.groupCounts[groupIndex] && (
|
||||
item={(index, groupIndex) => {
|
||||
if (!notes.groupCounts[groupIndex] || !notes.items[index]) return;
|
||||
return (
|
||||
<Note index={index} pinnable={true} item={notes.items[index]} />
|
||||
)
|
||||
}
|
||||
);
|
||||
}}
|
||||
/>
|
||||
</ListContainer>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user