schiehll / react-alert

alerts for React
MIT License
608 stars 98 forks source link

TypeScript #167

Closed krau5 closed 3 years ago

krau5 commented 3 years ago

Types for react-alert-template-basic does not exist

heitzlki commented 3 years ago

For me worked creating a file react-alert-template-basic.d.ts and put declare module 'react-alert-template-basic'; in it.

krau5 commented 3 years ago

I don't want to create file, I just wanna install this library and continue working

Aathi commented 3 years ago

@Krausso
AlertTemplate.zip Download the above folder and create a libs directory and use it like below

import React from "react";
import AlertTemplate from "../libs/AlertTemplate";
import App from "../App";

const options = {
    timeout: 50000,
    position: positions.BOTTOM_CENTER
  };

const IndexPage: React.FC<{}> = (props) => {
    return (
        <Provider template={AlertTemplate} {...options}>
             <App/>
        </Provider>
     )
}
codeysha commented 3 years ago

In the example above options should be typed as const options: AlertPosition | any = {... and template as const AlertTemplate: ComponentType<AlertComponentPropsWithStyle> = ({ options, message, close } : any) => (

Working fine