question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReactKonva does not support the type "Transformer"

See original GitHub issue

when i use Transformer like this:

<Transformer>
    <Image
        image={this.state.image}
        draggable
        onClick={() => {
            this.imageNode.moveToTop();
            this.imageNode.getLayer().batchDraw();
        }}
        y={250}
        ref={node => {
            this.imageNode = node;
        }}
    />
</Transformer>;

i got an error:ReactKonva does not support the type “Transformer” What is the correct usage of the Transformer?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Chubzorzcommented, Oct 29, 2019

I know this issue is already closed but I found that using a custom hook to create a transformer worked quite nicely.

const useTransformer = (nodeRef: RefObject<Konva.Node>) => {
  const transformerRef = useRef<Konva.Transformer>(null)

  useEffect(() => {
    if (!transformerRef.current || !nodeRef.current) return

    transformerRef.current.setNode(nodeRef.current)
    transformerRef.current.getLayer()!.batchDraw()
  }, [nodeRef, transformerRef])

  const transformer: React.FC<Konva.TransformerConfig> = ({children, ...rest}) => (
    <KonvaTransformer {...rest} ref={transformerRef}>
      {children}
    </KonvaTransformer>
  )

  return transformer
}
2reactions
lavrtoncommented, Mar 25, 2018

What version of react-konva are you using? Try to use the last one.

Currently, there is no good “react-way” usage of Transformer. But there is a way: https://codesandbox.io/s/vv6m43q9y7

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to resize and rotate canvas shapes with react ...
The transformer is always trying to match rotation of the attached node. As you reset it to 0, transformer is reset too. The...
Read more >
React Konva Transformer Error "Cannot read property ...
I'm using Konva 4.0.18 within a React 16.8. Application, which works well so far in the Standalone (CRA). When integrating this working ...
Read more >
konvajs/konva - Gitter
@lavrton I have a problem now. I have two layers. The lower layer element is added to the transformer, and the upper layer...
Read more >
Working with Canvas: Build a diagram tool in ReactJS
We will be using react for managing our DOM view layer, konva.js (and it's React ... Now we need to allow them to...
Read more >
React konva whiteboard - Hutton
All the parameters available for Konva objects are valid props for. ... But it has no support of events of shapes. react-konva vs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found