Search code examples
react-konva

how to access react-konva “stage” or “layer” from event handler?


How would one access the “stage” or “layer” from an event hanlde when using react-konva? (i.e. with JSX)

For example in this example: https://konvajs.org/docs/react/index.html, how would one access stage or layer in the event handler if one wanted to do a “find”, to search for a particular canvas node…


Solution

  • onClick={(e) => {
       const stage = e.target.getStage();
       const layer = e.target.getLayer();
    }}