Skip to content

Feat: preact#37

Merged
zaewc merged 8 commits into
developfrom
feat/preact-adapter
May 19, 2026
Merged

Feat: preact#37
zaewc merged 8 commits into
developfrom
feat/preact-adapter

Conversation

@zaewc

@zaewc zaewc commented Mar 30, 2026

Copy link
Copy Markdown
Owner

No description provided.

@github-actions

Copy link
Copy Markdown

📊 Test Coverage Report (vitest)

Package Statements Branches Functions Lines
@scrolloop/core 218/218 (100%) 53/53 (100%) 25/25 (100%) 218/218 (100%)
@scrolloop/react 420/715 (58.74%) 73/89 (82.02%) 5/17 (29.41%) 420/715 (58.74%)
@scrolloop/react-native 0/233 (0%) 1/4 (25%) 1/4 (25%) 0/233 (0%)
@scrolloop/shared 176/176 (100%) 54/54 (100%) 14/14 (100%) 176/176 (100%)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces the @scrolloop/preact package, which provides virtualization and infinite scrolling components for Preact. The implementation includes VirtualList, InfiniteList, and a useInfinitePages hook. Review feedback focuses on performance optimizations, specifically recommending the memoization of style objects and the extraction of inline styles into constants. Additionally, it is suggested to exclude the source directory from the published package to minimize its size.

Comment on lines +18 to +19
"dist",
"src"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Including the src directory in the files array increases the size of the published package. For a library, it's common practice to only include the compiled dist folder. Consider removing src unless there's a specific reason to publish the source files.

    "dist"

Comment on lines +54 to +59
const centerStyle: CSSProperties = {
height,
display: "flex",
alignItems: "center",
justifyContent: "center",
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The centerStyle object is recreated on every render. To optimize performance, you can memoize it using the useMemo hook, as it only depends on the height prop.

Suggested change
const centerStyle: CSSProperties = {
height,
display: "flex",
alignItems: "center",
justifyContent: "center",
};
const centerStyle = useMemo<CSSProperties>(() => ({
height,
display: "flex",
alignItems: "center",
justifyContent: "center",
}), [height]);

Comment on lines +66 to +75
<div style={{ textAlign: "center" }}>
<p>Error.</p>
<p style={{ color: "#666", fontSize: "0.9em" }}>{error.message}</p>
<button
onClick={retry}
style={{ marginTop: 8, padding: "4px 12px", cursor: "pointer" }}
>
Retry
</button>
</div>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These inline styles are recreated on each render and use magic values. It's better to extract them into constants for performance and maintainability. Since these styles don't depend on props, they can be defined outside the component.

For example:

const errorWrapperStyle: CSSProperties = { textAlign: 'center' };
const errorMessageStyle: CSSProperties = { color: '#666', fontSize: '0.9em' };
const retryButtonStyle: CSSProperties = { marginTop: 8, padding: '4px 12px', cursor: 'pointer' };

// ... inside the component
<div style={errorWrapperStyle}>
  <p>Error.</p>
  <p style={errorMessageStyle}>{error.message}</p>
  <button onClick={retry} style={retryButtonStyle}>
    Retry
  </button>
</div>

Comment on lines +90 to +94
const containerStyle: CSSProperties = {
overflow: "auto",
height,
...style,
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The containerStyle object is recreated on every render. To improve performance, you can memoize it using the useMemo hook since its dependencies (height and style) are props.

Suggested change
const containerStyle: CSSProperties = {
overflow: "auto",
height,
...style,
};
const containerStyle = useMemo<CSSProperties>(() => ({
overflow: "auto",
height,
...style,
}), [height, style]);

@github-actions

Copy link
Copy Markdown

📊 Test Coverage Report (vitest)

Package Statements Branches Functions Lines
@scrolloop/core 218/218 (100%) 53/53 (100%) 25/25 (100%) 218/218 (100%)
@scrolloop/react 420/715 (58.74%) 73/89 (82.02%) 5/17 (29.41%) 420/715 (58.74%)
@scrolloop/react-native 0/233 (0%) 1/4 (25%) 1/4 (25%) 0/233 (0%)
@scrolloop/shared 176/176 (100%) 54/54 (100%) 14/14 (100%) 176/176 (100%)

@github-actions

Copy link
Copy Markdown

📊 Test Coverage Report (vitest)

Package Statements Branches Functions Lines
@scrolloop/core 218/218 (100%) 53/53 (100%) 25/25 (100%) 218/218 (100%)
@scrolloop/react 420/715 (58.74%) 73/89 (82.02%) 5/17 (29.41%) 420/715 (58.74%)
@scrolloop/react-native 0/233 (0%) 1/4 (25%) 1/4 (25%) 0/233 (0%)
@scrolloop/shared 176/176 (100%) 54/54 (100%) 14/14 (100%) 176/176 (100%)

@zaewc zaewc merged commit 45e0224 into develop May 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant