0

When using react-konva in a react web application I'm noting using the JSX tags I do not have direct handles to the various nodes I create on a Layer/Canvas. Then I have to get access to the Layer and use "find" to find the nodes to then modify them.

It would be perhaps easier not using the JSX tags (e.g. Rect, Text etc) and just create them programmatically, that way I would have a handle to the objects to later modify. (e.g. if I drag node A, I want then move node B in real time along with it).

Question - Is there any disadvange to NOT using the react-konvas JSX approach? For example does creating canvas with JSX tags (e.g. for Circle, Rect, Text etc) help reduce the amount of "redraw" effect perhaps?

Greg
  • 34,042
  • 79
  • 253
  • 454

1 Answers1

1

You can use Konva API directly just fine. It will work.

Using react-konva is just a lot more natural when you have a React app. As you will use the same paradigm for canvas drawing. Depending on your app size, it can simplify code a lot!

lavrton
  • 18,973
  • 4
  • 30
  • 63
  • Was wondering if the react JSX tags assist in only re-rendering nodes when they change? If this makes sense? – Greg Jun 18 '22 at 03:26
  • @Greg it depends on your meaning of "re-rendering". react-konva will update only changed nodes. But drawing on the canvas is literally clearing it first, and render EVERY node again. That will be done by Konva framework. And that is the default behabiour (without or without react). – lavrton Jun 19 '22 at 04:47
  • @lavrton I saw react-konva is dependent on react-reconciler which mentions its an unstable api. Is that something that should be considered according to you? or is it fair to say its not going to be a significant risk – Fyre Oct 30 '22 at 19:23
  • There are many huge projects that depend on `react-reconciler`. So, I think it is safe to use it. Unstable means it may change. In that case, we will just adapt react-konva. – lavrton Nov 02 '22 at 20:27