Skip to content

How to implement GestureHandler on a state of array through map? #1752

Closed Answered by anovius
anovius asked this question in Q&A
Discussion options

You must be logged in to vote

I have resolved this by making a matrix in the child component using useValue(Skia.Matrix()) hook and passing and setting up a state of an array of matrixes in the parent component. Here are some codes snippets that might help.

Canvas.jsx

`

      const [texts, setTexts] = useState([]);
      const [textMatrixes, setTextMatrixes] = useState([]);
      const [text, setText] = useState('');

      const addMatrixes = (mat) => {
          setTextMatrixes([...textMatrixes, mat]);
      }

      const onAddTextPress = () => {
          setTexts([...texts, {text}])
          setText('')
          setActiveTool('')
      }

      <Canvas ref={canvas} style={styles.photo}>
          {texts.map((t,…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by anovius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant