Skip to content

Add SSR support - #70

Merged
emdap merged 3 commits into
masterfrom
ssr-support
Aug 10, 2026
Merged

Add SSR support#70
emdap merged 3 commits into
masterfrom
ssr-support

Conversation

@emdap

@emdap emdap commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This moves the scrollbar width measurement into an effect so that it won't run during SSR.

To test this out, I linked my locally built react-custom-scroller to a repo that has prerendering enabled, and verified that there were no errors while running or building.

@emdap
emdap requested review from buzinas and treycucco August 6, 2026 21:26

@treycucco treycucco left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This looks like a good change Emma. I want to have Vitor look over it since I haven't done anything in this repo. My main suggestions, listed in the comments below is this:

Don't unconditionally call set state, use the cached value being defined to bail out. Default the state to use the cached value, or fallback if necessary. And wrap all that logic (the state and the effect) into a named hook that only returns the width, so all the hooks dealing with reading and calculating the width are batched up together.

Comment thread src/useCustomScroller.ts Outdated
Comment thread src/useCustomScroller.ts Outdated
@linear-code

linear-code Bot commented Aug 7, 2026

Copy link
Copy Markdown

GRO-677

@buzinas buzinas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall looks good, but I'm wondering if we could avoid the effect by just letting the calculation happens as it did before.

Comment thread src/useCustomScroller.ts Outdated
Comment thread src/useCustomScroller.ts Outdated
@emdap
emdap merged commit 2a85537 into master Aug 10, 2026
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.

3 participants