Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

Support for React 18 & typescript #142

Open
leeprobert opened this issue May 12, 2022 · 3 comments
Open

Support for React 18 & typescript #142

leeprobert opened this issue May 12, 2022 · 3 comments

Comments

@leeprobert
Copy link

Had to --force the package to install under react@18.1.0 and also had issues with Typescript types that was resolved with npm i --save-dev @types/react-canvas-draw --force

@leeprobert
Copy link
Author

Actually still getting errors with typescript: Could not find a declaration file for module 'react-canvas-draw' - the recommended resolution (above) didn't work after all.

@leeprobert
Copy link
Author

The solution for typescript is to add a file called type.d.ts and put this line in it: declare module 'react-canvas-draw'; - that will be enough for the compiler to accept the import of the module.

@leeprobert leeprobert changed the title Support for React 18 Support for React 18 & typescript May 12, 2022
@leeprobert
Copy link
Author

If you need to start doing anything useful with this component in Typescript you'll have to start declaring all the types. My declaration file is currently:

import CanvasDraw from "react-canvas-draw";

// this is required for Typescript to recognise the CanvasDraw package
declare module 'react-canvas-draw'{
    canvasDraw: CanvasDraw | null;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant