Trying to use React Native Canvas with Gesture Responder in Views #250
Replies: 5 comments
-
You should save |
Beta Was this translation helpful? Give feedback.
-
Hi @iddan, thanks for the response. Would that be as a variable in constructor, like:
this.setState({ctx: canvas.getContext("2d")}) always returns undefined so does not work. |
Beta Was this translation helpful? Give feedback.
-
Yeah, the code you provided is okay. Just make sure to check canvas is not null |
Beta Was this translation helpful? Give feedback.
-
Hi @iddan, I now have another problem. When running this package with a blank Expo project, I encapsulate the Canvas example with a View in order to style it, but anytime I make some changes to my code and hot-reload the app, I get a RedBox error: "undefined is not an object (at this.handleCanvas)" but the stack trace points to withExpoRoot.js, not any line within my code. Screenshots of the code here: |
Beta Was this translation helpful? Give feedback.
-
Please provide code examples with code blocks. I have not used expo so I'm not sure why is it happening. Maybe someone else here can help? |
Beta Was this translation helpful? Give feedback.
-
Hi all,
I'm trying to use React Native Canvas to build a Canvas tool for drawing DFAs. I'm trying
to create this from the Javascript version (excerpt below).
However, in React Native the ctx variable only exists within the handleCanvas() method in the example given in the repo, whereas I want to use GestureResponder to execute drawCircle() on any touch on the . How can I store/handle the value of ctx to be able to draw outside handleCanvas(), so I can execute drawCircle() on any touch on the view. The RN code is given below:
Beta Was this translation helpful? Give feedback.
All reactions