From 3c44033e4ebafd28472d5c6a43e55c0363c6b555 Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Thu, 1 Dec 2022 12:41:37 -0400 Subject: [PATCH] Show warning about hydrating Astro components in build (#5501) * Also show the warning in build when trying to hydrate an Astro component * Add changeset --- .changeset/yellow-lizards-shout.md | 5 +++++ packages/astro/src/runtime/server/render/astro.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .changeset/yellow-lizards-shout.md diff --git a/.changeset/yellow-lizards-shout.md b/.changeset/yellow-lizards-shout.md new file mode 100644 index 000000000000..10974c86c143 --- /dev/null +++ b/.changeset/yellow-lizards-shout.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Added a warning in build when trying to hydrate an Astro component diff --git a/packages/astro/src/runtime/server/render/astro.ts b/packages/astro/src/runtime/server/render/astro.ts index 3283669c0eee..077bc6ca24d0 100644 --- a/packages/astro/src/runtime/server/render/astro.ts +++ b/packages/astro/src/runtime/server/render/astro.ts @@ -8,9 +8,9 @@ import { isPromise } from '../util.js'; import { renderChild } from './any.js'; import { HTMLParts } from './common.js'; -// In dev mode, check props and make sure they are valid for an Astro component +// Issue warnings for invalid props for Astro components function validateComponentProps(props: any, displayName: string) { - if (import.meta.env?.DEV && props != null) { + if (props != null) { for (const prop of Object.keys(props)) { if (HydrationDirectiveProps.has(prop)) { // eslint-disable-next-line