Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions docs/blog/2025-12-01-release-1-20/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Curious about what’s new? Let’s dive in!

<!-- truncate -->

import Head from "@docusaurus/Head";
import ExpoSnack from "@site/src/components/ExpoSnack";

## Expo Snack support

Expand All @@ -22,24 +22,7 @@ With version `1.20.0`, that limitation is finally gone. The library now works se

Below is an embedded Snack that includes the code I used for my [AppJS Conf](https://appjs.co) demo this year:

<div
data-snack-id="@kirylziusko/chat-keyboard-avoiding-view"
data-snack-platform="ios"
data-snack-preview="true"
data-snack-theme="light"
style={{
overflow: "hidden",
background: "#fbfcfd",
border: "1px solid var(--color-border)",
borderRadius: 4,
height: 505,
width: "100%",
}}
></div>

<Head>
<script src="https://snack.expo.dev/embed.js" async />
</Head>
<ExpoSnack id="@kirylziusko/chat-keyboard-avoiding-view" />

<br />

Expand Down
21 changes: 3 additions & 18 deletions docs/docs/api/components/keyboard-chat-scroll-view.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -231,24 +231,9 @@ const memoList = useCallback(

## Example

<div
data-snack-id="@kirylziusko/c0b7f0"
data-snack-platform="ios"
data-snack-preview="true"
data-snack-theme="light"
style={{
overflow: "hidden",
background: "#fbfcfd",
border: "1px solid var(--color-border)",
borderRadius: 4,
height: 505,
width: "100%",
}}
></div>

<Head>
<script src="https://snack.expo.dev/embed.js" async />
</Head>
import ExpoSnack from "@site/src/components/ExpoSnack";

<ExpoSnack id="@kirylziusko/c0b7f0" />

## Design principles

Expand Down
21 changes: 3 additions & 18 deletions docs/docs/guides/building-chat-app.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -489,24 +489,9 @@ function ChatScreen() {

Or play with the code in live mode directly in the browser:

<div
data-snack-id="@kirylziusko/c0b7f0"
data-snack-platform="ios"
data-snack-preview="true"
data-snack-theme="light"
style={{
overflow: "hidden",
background: "#fbfcfd",
border: "1px solid var(--color-border)",
borderRadius: 4,
height: 505,
width: "100%",
}}
></div>

<Head>
<script src="https://snack.expo.dev/embed.js" async />
</Head>
import ExpoSnack from "@site/src/components/ExpoSnack";

<ExpoSnack id="@kirylziusko/c0b7f0" />

## API reference

Expand Down
56 changes: 56 additions & 0 deletions docs/src/components/ExpoSnack/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { useEffect } from "react";

type ExpoSnackProps = {
id: string;
platform?: string;
preview?: boolean;
theme?: string;
};

declare global {
interface Window {
ExpoSnack?: { initialize: () => void };
}
}

const EMBED_SCRIPT_SRC = "https://snack.expo.dev/embed.js";

export default function ExpoSnack({
id,
platform = "ios",
preview = true,
theme = "light",
}: ExpoSnackProps) {
useEffect(() => {
const existing = document.querySelector(
`script[src="${EMBED_SCRIPT_SRC}"]`,
);

if (!existing) {
const script = document.createElement("script");

script.src = EMBED_SCRIPT_SRC;
script.async = true;
document.head.appendChild(script);
} else if (window.ExpoSnack) {
window.ExpoSnack.initialize();
}
}, []);

return (
<div
data-snack-id={id}
data-snack-platform={platform}
data-snack-preview={String(preview)}
data-snack-theme={theme}
style={{
overflow: "hidden",
background: "#fbfcfd",
border: "1px solid var(--color-border)",
borderRadius: 4,
height: 505,
width: "100%",
}}
/>
);
}
Loading