Skip to content

Migrating to ^1.5.0 (useTouchHandler and onTouch deprecation) guide? #2859

Answered by VicHofs
VicHofs asked this question in Q&A
Discussion options

You must be logged in to vote

I arrived at this solution:

import { useRef, useState, Children } from "react";
import { View } from "react-native";
import { Gesture, GestureDetector } from "react-native-gesture-handler";
import { runOnJS } from "react-native-reanimated";
import { Path, SkPath, Skia, Canvas } from "@shopify/react-native-skia";

const DrawingCanvas = () => {
  const currentPath = useRef<SkPath | null>(null);
  const [paths, setPaths] = useState<SkPath[]>([]);

  const updatePaths = useCallback((newPath: SkPath) => {
      setPaths((prevState) => [...prevState, newPath]);
    }, []);

    const drawGesture = Gesture.Pan()
      .runOnJS(true)
      .onBegin(({x, y}) => {
        currentPath.current = Skia.P…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by VicHofs
Comment options

You must be logged in to vote
1 reply
@VicHofs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants