diff --git a/examples/chat.tsx b/examples/chat.tsx index cdae95c1d..c7dee50ef 100644 --- a/examples/chat.tsx +++ b/examples/chat.tsx @@ -71,10 +71,11 @@ function ChatList({ userId, messages = [], onSend, onReceive, placeholder }: Cha } const row = React.useMemo( - () => (i: number, { message, id }: { message: string; id: string }) => { - const fromUser = id === userId - return - }, + () => + (i: number, { message, id }: { message: string; id: string }) => { + const fromUser = id === userId + return + }, [userId] ) @@ -127,7 +128,7 @@ function ChatList({ userId, messages = [], onSend, onReceive, placeholder }: Cha } const data = Array.from({ length: 130 }, (_) => ({ - id: faker.random.number({ min: 1, max: 2 }).toString(), + id: faker.datatype.number({ min: 1, max: 2 }).toString(), message: faker.lorem.sentences(), })) diff --git a/examples/empty-placeholder.tsx b/examples/empty-placeholder.tsx index 955760947..e9f213a7a 100644 --- a/examples/empty-placeholder.tsx +++ b/examples/empty-placeholder.tsx @@ -10,12 +10,16 @@ export default function App() { `item-${key}`} components={{ - EmptyPlaceholder: () =>
Nothing to See here!
, + EmptyPlaceholder: () => { + console.log('empty placeholder rendered') + return
Nothing to See here!
+ }, }} totalCount={totalCount} itemContent={(index) =>
Item {index}
} style={{ height: 300 }} /> +

Empty placeholder should not be flashed in default rendering. check the console for logs.

) } diff --git a/src/listStateSystem.ts b/src/listStateSystem.ts index 256c94434..d2cdeeb64 100644 --- a/src/listStateSystem.ts +++ b/src/listStateSystem.ts @@ -191,7 +191,7 @@ export const listStateSystem = u.system( const { sizeTree, offsetTree } = sizesValue if (totalCount === 0 || (startOffset === 0 && endOffset === 0)) { - return EMPTY_LIST_STATE + return { ...EMPTY_LIST_STATE, totalCount } } if (empty(sizeTree)) {