summaryrefslogtreecommitdiff
path: root/packages/integrations
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations')
-rw-r--r--packages/integrations/preact/src/server.ts20
-rw-r--r--packages/integrations/react/server-v17.js18
-rw-r--r--packages/integrations/react/server.js18
-rw-r--r--packages/integrations/solid/src/server.ts16
4 files changed, 21 insertions, 51 deletions
diff --git a/packages/integrations/preact/src/server.ts b/packages/integrations/preact/src/server.ts
index 932cacb99..5b38ff590 100644
--- a/packages/integrations/preact/src/server.ts
+++ b/packages/integrations/preact/src/server.ts
@@ -27,19 +27,17 @@ async function check(
useConsoleFilter();
try {
- try {
- const { html } = await renderToStaticMarkup.call(this, Component, props, children, undefined);
- if (typeof html !== 'string') {
- return false;
- }
-
- // There are edge cases (SolidJS) where Preact *might* render a string,
- // but components would be <undefined></undefined>
- // It also might render an empty sting.
- return html == '' ? false : !html.includes('<undefined>');
- } catch {
+ const { html } = await renderToStaticMarkup.call(this, Component, props, children, undefined);
+ if (typeof html !== 'string') {
return false;
}
+
+ // There are edge cases (SolidJS) where Preact *might* render a string,
+ // but components would be <undefined></undefined>
+ // It also might render an empty sting.
+ return html == '' ? false : !html.includes('<undefined>');
+ } catch {
+ return false;
} finally {
finishUsingConsoleFilter();
}
diff --git a/packages/integrations/react/server-v17.js b/packages/integrations/react/server-v17.js
index 16f6fcdcd..4e577883a 100644
--- a/packages/integrations/react/server-v17.js
+++ b/packages/integrations/react/server-v17.js
@@ -5,14 +5,6 @@ import StaticHtml from './static-html.js';
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const reactTypeof = Symbol.for('react.element');
-function errorIsComingFromPreactComponent(err) {
- return (
- err.message &&
- (err.message.startsWith("Cannot read property '__H'") ||
- err.message.includes("(reading '__H')"))
- );
-}
-
function check(Component, props, children) {
// Note: there are packages that do some unholy things to create "components".
// Checking the $$typeof property catches most of these patterns.
@@ -26,7 +18,6 @@ function check(Component, props, children) {
return React.Component.isPrototypeOf(Component) || React.PureComponent.isPrototypeOf(Component);
}
- let error = null;
let isReactComponent = false;
function Tester(...args) {
try {
@@ -34,20 +25,13 @@ function check(Component, props, children) {
if (vnode && vnode['$$typeof'] === reactTypeof) {
isReactComponent = true;
}
- } catch (err) {
- if (!errorIsComingFromPreactComponent(err)) {
- error = err;
- }
- }
+ } catch {}
return React.createElement('div');
}
renderToStaticMarkup(Tester, props, children, {});
- if (error) {
- throw error;
- }
return isReactComponent;
}
diff --git a/packages/integrations/react/server.js b/packages/integrations/react/server.js
index 3907ba6f1..69b0a8e12 100644
--- a/packages/integrations/react/server.js
+++ b/packages/integrations/react/server.js
@@ -7,14 +7,6 @@ import StaticHtml from './static-html.js';
const slotName = (str) => str.trim().replace(/[-_]([a-z])/g, (_, w) => w.toUpperCase());
const reactTypeof = Symbol.for('react.element');
-function errorIsComingFromPreactComponent(err) {
- return (
- err.message &&
- (err.message.startsWith("Cannot read property '__H'") ||
- err.message.includes("(reading '__H')"))
- );
-}
-
async function check(Component, props, children) {
// Note: there are packages that do some unholy things to create "components".
// Checking the $$typeof property catches most of these patterns.
@@ -32,7 +24,6 @@ async function check(Component, props, children) {
return React.Component.isPrototypeOf(Component) || React.PureComponent.isPrototypeOf(Component);
}
- let error = null;
let isReactComponent = false;
function Tester(...args) {
try {
@@ -40,20 +31,13 @@ async function check(Component, props, children) {
if (vnode && vnode['$$typeof'] === reactTypeof) {
isReactComponent = true;
}
- } catch (err) {
- if (!errorIsComingFromPreactComponent(err)) {
- error = err;
- }
- }
+ } catch {}
return React.createElement('div');
}
await renderToStaticMarkup(Tester, props, children, {});
- if (error) {
- throw error;
- }
return isReactComponent;
}
diff --git a/packages/integrations/solid/src/server.ts b/packages/integrations/solid/src/server.ts
index a352dfa5a..295771265 100644
--- a/packages/integrations/solid/src/server.ts
+++ b/packages/integrations/solid/src/server.ts
@@ -28,12 +28,16 @@ async function check(
// In general, components from other frameworks (eg, MDX, React, etc.) tend to render as "undefined",
// so we take advantage of this trick to decide if this is a Solid component or not.
- const { html } = await renderToStaticMarkup.call(this, Component, props, children, {
- // The purpose of check() is just to validate that this is a Solid component and not
- // React, etc. We should render in sync mode which should skip Suspense boundaries
- // or loading resources like external API calls.
- renderStrategy: 'sync' as RenderStrategy,
- });
+ let html: string | undefined;
+ try {
+ const result = await renderToStaticMarkup.call(this, Component, props, children, {
+ // The purpose of check() is just to validate that this is a Solid component and not
+ // React, etc. We should render in sync mode which should skip Suspense boundaries
+ // or loading resources like external API calls.
+ renderStrategy: 'sync' as RenderStrategy,
+ });
+ html = result.html;
+ } catch {}
return typeof html === 'string';
}