Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has anyone managed to get this working with TypeScript? #5

Closed
sheam opened this issue May 29, 2017 · 2 comments · Fixed by #42
Closed

has anyone managed to get this working with TypeScript? #5

sheam opened this issue May 29, 2017 · 2 comments · Fixed by #42
Labels
kind: feature New feature or request kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core) scope: types Related to type definitions

Comments

@sheam
Copy link

sheam commented May 29, 2017

I tried creating a declaration file index.d.ts:

declare module 'react-signature-canvas'
{
    import * as React from 'react';
    
    interface ISignatureCanvasProps
    {
        velocityFilterWeight?: number;
        minWidth?: number;
        maxWidth?: number;
        dotSize?: number;
        penColor?: string;
        backgroundColor?: string;
        onEnd?: () => void;
        onBegin?: () => void;
        canvasProps?: any;
    }
    
    export class SignatureCanvas extends React.Component<ISignatureCanvasProps, any>
    {
        constructor(p: ISignatureCanvasProps, s: any);
    }
    
    namespace SignatureCanvas {}
}

And then importing via: import * as SignatureCanvas from 'react-signature-canvas';.

But when I use the <SignatureCanvas /> in my react component I get
React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object

Any ideas?

@sheam
Copy link
Author

sheam commented Jun 1, 2017

This typings file works:

declare module 'react-signature-canvas'
{
    import * as React from 'react';

    interface ISignatureCanvasProps
    {
        velocityFilterWeight?: number;
        minWidth?: number;
        maxWidth?: number;
        dotSize?: number;
        penColor?: string;
        backgroundColor?: string;
        onEnd?: () => void;
        onBegin?: () => void;
        canvasProps?:
        {
            width?: number;
            height?: number;
        };
    }

    class SignatureCanvas extends React.Component<ISignatureCanvasProps, any>
    {
        constructor(p: ISignatureCanvasProps, s: any);
        clear(): void;
        isEmpty(): boolean;
        fromDataURL(base64String: string): void;
        getCanvas(): HTMLCanvasElement;
        getTrimmedCanvas(): HTMLCanvasElement;
    }

    export default SignatureCanvas;
}

Freel free to add this as index.d.ts to your project.

@sheam sheam closed this as completed Jun 1, 2017
@agilgur5 agilgur5 added the scope: types Related to type definitions label Jan 18, 2020
Repository owner locked as resolved and limited conversation to collaborators Feb 5, 2022
@agilgur5
Copy link
Owner

agilgur5 commented Feb 5, 2022

This was superseded by #21 and #42, so locking this as resolved now

@agilgur5 agilgur5 added kind: feature New feature or request kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core) labels Sep 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind: feature New feature or request kind: support Asking for support with something or a specific use case scope: integration Related to an integration, not necessarily to core (but could influence core) scope: types Related to type definitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants