BenJeau / react-native-draw

SVG based data-driven React Native drawing component 🎨
https://www.npmjs.com/package/@benjeau/react-native-draw
MIT License
129 stars 42 forks source link

Drawing is not working, I have use given example #43

Closed Anubhavshakya closed 2 years ago

Anubhavshakya commented 2 years ago

Please provide correct example to use it. In my case UI is rendering but it does not draw anything.

BenJeau commented 2 years ago

I am assuming that you have not properly setup https://docs.swmansion.com/react-native-gesture-handler/, since the whole drawing relies on react-native-gesture-handler. Please follow the setup instructions on their docs and let me know if it still doesn't work afterwards.

I just tried creating a new react native project with this library and it is working (there were only some small syntax issues in the example, which I just fixed).

Anubhavshakya commented 2 years ago

First of all thank you for quick response, I have setup this project using expo managed. I have tried many ways but it still does not draw anything. I am attaching the UI and my Code. Can you provide me working example repo ?? so that it can help me. WhatsApp Image 2022-02-02 at 10 56 24 PM

`import React, { useRef } from 'react'; import { Draw, DrawRef } from "@benjeau/react-native-draw";

export default function App() { const drawRef = useRef(null);

const removeLastPath = () => { drawRef.current?.undo(); }

const clearDrawing = () => { drawRef.current?.clear(); }

// ... for more ref functions, look below

return ( <Draw ref={drawRef} height={600} initialValues={{ color: "#B644D0", thickness: 10, opacity: 0.5, paths: [] }} /> ) }`

BenJeau commented 2 years ago

Have you tried running the example? (although the code inside may seem a bit weird, just picture that the objects in the data variable in the data.ts file as props to the component, more specifically the props object of the data variable)

It is using Expo and should be working on Android and iOS (web has a problem with one of the dependencies).

If that is not enough, I can create a small repo with only the example.