skip to Main Content

I import component as:

import {Slide as ReSlide} from 'react-awesome-reveal';

the code as :

       <ReSlide direction="up"  delay={-100}>         
            </ReSlide>

and on js working fine but i use it on tsx they give me error :
"JSX element type ‘ReSlide’ does not have any construct or call signatures."
how to solve it i have to make build of project!

2

Answers


  1. Chosen as BEST ANSWER

    I sold the problem with reinstall the package agine and it work fine i think the diffent was on the package


  2. Try this ccreate a file named react-awesome-reveal.d.ts (you can name it differently if you prefer) at the same level as your other TypeScript files.

    Inside this file, define the type for the Slide component from the react-awesome-reveal module:

        declare module 'react-awesome-reveal' {
          import * as React from 'react';
        
          export interface SlideProps {
            direction?: string;
            delay?: number;
            children: React.ReactNode;
          }
        
          export const Slide: React.FC<SlideProps>;
        }
    

    This declaration file tells TypeScript how to interpret the Slide component from the react-awesome-reveal module and what props it accepts.

    Now, in your TypeScript file (.tsx), you can import and use the ReSlide component without any errors:

        <ReSlide direction="up" delay={-100}>
              {/* Your content */}
            </ReSlide>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search