fix(embeds): add support for RSC by adding use client directives (#7919)

This commit is contained in:
Julius Marminge authored and GitHub committed 2023-03-28 11:30:02 +05:30
1 parent 605f9c61f3
commit 1620ae660f
13 files changed
+187 -1847

No files matched your search

@@ -344,13 +344,15 @@ function keepParentInformedAboutDimensionChanges() {
// Use, .height as that gives more accurate value in floating point. Also, do a ceil on the total sum so that whatever happens there is enough iframe size to avoid scroll.
const contentHeight = Math.ceil(
parseFloat(mainElementStyles.height) +
parseFloat(mainElementStyles.marginTop) +
parseFloat(mainElementStyles.marginBottom));
parseFloat(mainElementStyles.marginTop) +
parseFloat(mainElementStyles.marginBottom)
);
const contentWidth = Math.ceil(
parseFloat(mainElementStyles.width) +
parseFloat(mainElementStyles.marginLeft) +
parseFloat(mainElementStyles.marginRight));
parseFloat(mainElementStyles.marginLeft) +
parseFloat(mainElementStyles.marginRight)
);
// During first render let iframe tell parent that how much is the expected height to avoid scroll.
// Parent would set the same value as the height of iframe which would prevent scroll.
// On subsequent renders, consider html height as the height of the iframe. If we don't do this, then if iframe get's bigger in height, it would never shrink
+2 -1
View File
@@ -1,4 +1,5 @@
/* eslint-disable prefer-const */
"use client";
import { useEffect, useRef } from "react";
import useEmbed from "./useEmbed";
+2
View File
@@ -1,3 +1,5 @@
"use client";
import type { GlobalCal } from "@calcom/embed-core";
import EmbedSnippet from "@calcom/embed-snippet";
@@ -1,3 +1,5 @@
"use client";
import { useEffect, useState } from "react";
import EmbedSnippet from "@calcom/embed-snippet";
+1 -2
View File
@@ -1,5 +1,4 @@
import { useEffect } from "react";
import { useState } from "react";
import React, { useEffect, useState } from "react";
import ReactDom from "react-dom";
import Cal, { getCalApi } from "./src/index";