import { Dimensions, LayoutRectangle, SafeAreaView, StyleSheet, Text, View, } from "react-native"; import React, { useEffect, useRef, useState } from "react"; import Canvas from "react-native-canvas"; import { Platform } from "react-native"; type Props = {}; const Grid = (props: Props) => { const canvasRef = useRef(null); const [layout, setLayout] = useState(); useEffect(() => { if (canvasRef.current && layout) { canvasRef.current.width = Dimensions.get("window").width; canvasRef.current.height = layout.height; const ctx = canvasRef.current.getContext("2d"); ctx.beginPath(); ctx.strokeStyle = "white"; ctx.moveTo(canvasRef.current.width / 3, 0); ctx.lineTo(canvasRef.current.width / 3, canvasRef.current.height); ctx.moveTo((canvasRef.current.width * 2) / 3, 0); ctx.lineTo((canvasRef.current.width * 2) / 3, canvasRef.current.height); ctx.moveTo(0, canvasRef.current.height / 3); ctx.lineTo(canvasRef.current.width, canvasRef.current.height / 3); ctx.moveTo(0, (canvasRef.current.height * 2) / 3); ctx.lineTo(canvasRef.current.width, (canvasRef.current.height * 2) / 3); ctx.stroke(); } }, [layout]); return ( // { setLayout(e.nativeEvent.layout); }} > // ); }; export default Grid; const styles = StyleSheet.create({ root: { flex: 1, zIndex: 2, overflow: "hidden", }, grid: { alignSelf: "center", width: "100%", height: "100%", bottom: Platform.OS === "ios" ? 30 : 0, }, });