Skip to content
Open
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
17 changes: 9 additions & 8 deletions apps/example/src/Tests/Tests.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-nested-ternary */
/* eslint-disable no-eval */
/* eslint-disable @typescript-eslint/no-explicit-any */
import {
Expand All @@ -9,7 +10,7 @@ import {
} from "@shopify/react-native-skia";
import type { RefObject } from "react";
import React, { useEffect, useRef, useState } from "react";
import { PixelRatio, Text, View } from "react-native";
import { PixelRatio, Platform, Text, View } from "react-native";

import type { SerializedNode } from "./deserialize";
import { parseNode, parseProps } from "./deserialize";
Expand All @@ -20,7 +21,7 @@ export const CI = process.env.CI === "true";
const s = 3;
const scale = s / PixelRatio.get();
const size = 256 * scale;
const timeToDraw = CI ? 1500 : 500;
const timeToDraw = CI ? (Platform.OS === "ios" ? 1500 : 3000) : 500;

interface TestsProps {
assets: { [key: string]: any };
Expand All @@ -32,7 +33,7 @@ export const Tests = ({ assets }: TestsProps) => {
const [client, hostname] = useClient();
const [drawing, setDrawing] = useState<any>(null);
const [screen, setScreen] = useState<any>(null);

useEffect(() => {
if (client !== null) {
// Define the message handler as a separate function
Expand Down Expand Up @@ -66,16 +67,16 @@ export const Tests = ({ assets }: TestsProps) => {
};

// Use addEventListener instead of onmessage
client.addEventListener('message', handleMessage);
client.addEventListener("message", handleMessage);

// Clean up: remove the specific event listener
return () => {
client.removeEventListener('message', handleMessage);
client.removeEventListener("message", handleMessage);
};
}
return;
}, [assets, client]);

useEffect(() => {
if (drawing && client) {
const it = setTimeout(() => {
Expand Down Expand Up @@ -104,7 +105,7 @@ export const Tests = ({ assets }: TestsProps) => {
}
return;
}, [client, drawing, ref]);

useEffect(() => {
if (screen && client) {
const it = setTimeout(async () => {
Expand All @@ -120,7 +121,7 @@ export const Tests = ({ assets }: TestsProps) => {
}
return;
}, [client, screen]);

return (
<View style={{ flex: 1, backgroundColor: "white" }}>
<Text style={{ color: "black" }}>
Expand Down
2 changes: 1 addition & 1 deletion apps/example/src/Tests/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export const useClient = (): UseClient => {
ws.close();
// incrementing retry to rerun the effect
setRetry((r) => r + 1);
}, 500);
}, 3000);
};
return () => {
ws.close();
Expand Down
Loading