fix(vue-table): return null for empty string in FlexRender to prevent hydration mismatch #6186
main fromrefs/pull/6186/head·opened Problem#
When using @tanstack/vue-table with SSR (e.g., Nuxt), a hydration error occurs inside <td> elements when a column value is an empty string "".
As reported in #6077, Vue's server-side renderer produces no content for an empty string, while the client-side renderer creates an empty text node, causing a hydration mismatch.
Root Cause#
In the FlexRender component, when props.render is an empty string:
- It's not a function or object, so the
h()branch is skipped - It falls through to
return props.renderwhich returns"" - Vue SSR renders nothing for empty strings, but the client creates a text node
- This inconsistency triggers a hydration mismatch error
Fix#
Added an explicit check for nullish and empty string values before the fallthrough return, returning null instead. This ensures consistent rendering between server and client:
// Return null for empty/nullish values to avoid Vue SSR hydration
// mismatches
if (props.render == null || props.render === '') {
return null
}
Reproduction#
See the StackBlitz reproduction from the original issue.
Closes #6077
- 1
Important
Review skipped#
Auto reviews are disabled on base/target branches other than the default branch.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID:
dec5a4e7-c690-4bcf-b098-30715e0e6a09You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
- 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment `@coderabbitai help` to get the list of available commands and usage tips.KevinVandy closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: 87d8da9d3c6c2b43fd9f2a8c2dd11b3739c0d7ae
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR