Search code examples
typescriptkonvajsreact-konvakonvakonvajs-reactjs

Importing IReact type definition


I have a variable that holds a Group Reference and when I call getClientRect() it returns the "IReact" type.

Since IReact is not in the default types index should I import the type from the internal types file or is there a better approach?

Simplified code reference:

import { IRect } from './../../../node_modules/konva/types/types';

const groupRef: React.RefObject<Konva.Group> = React.createRef();
const groupAttrsAux: IRect | undefined = groupRef.current?.getClientRect(null);

Solution

  • You should never import from node_modules. Shouldn't this work?

    import { IRect } from "konva/types/types";