TypeScript 3: JSX element type 'Component' does not have any construct or call signatures. [2604]





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















I'm trying to pass a variable of type React.Component (or React.FunctionComponent) into a Route, like this:



import React from 'react';
import { Route } from 'react-router-dom';

type PrivateRouteProps = {
component: React.Component | React.FunctionComponent;
isAuthenticated: boolean;
login: (...args: any) => any;
path: string;
};

const PrivateRoute: React.FunctionComponent<PrivateRouteProps> = ({
component: Component,
isAuthenticated,
login,
path,
...rest
}) => {
return (
<Route
path={path}
{...rest}
render={props => {
if (isAuthenticated) {
return <Component {...props} />;
} else {
login();
return null;
}
}}
/>
);
};


But I'm getting this error:




JSX element type 'Component' does not have any construct or call signatures. [2604]




I've read through a bunch of other threads about this issue, but they all seem to deal with this error coming up for a specific component implementation. I can't change the component in question or import it differently (like the accepted answers often suggest), because it could be any component.



I'm using TypeScript 3.1.6, Babel Core 7.1, and React 16.6.3.










share|improve this question





























    2















    I'm trying to pass a variable of type React.Component (or React.FunctionComponent) into a Route, like this:



    import React from 'react';
    import { Route } from 'react-router-dom';

    type PrivateRouteProps = {
    component: React.Component | React.FunctionComponent;
    isAuthenticated: boolean;
    login: (...args: any) => any;
    path: string;
    };

    const PrivateRoute: React.FunctionComponent<PrivateRouteProps> = ({
    component: Component,
    isAuthenticated,
    login,
    path,
    ...rest
    }) => {
    return (
    <Route
    path={path}
    {...rest}
    render={props => {
    if (isAuthenticated) {
    return <Component {...props} />;
    } else {
    login();
    return null;
    }
    }}
    />
    );
    };


    But I'm getting this error:




    JSX element type 'Component' does not have any construct or call signatures. [2604]




    I've read through a bunch of other threads about this issue, but they all seem to deal with this error coming up for a specific component implementation. I can't change the component in question or import it differently (like the accepted answers often suggest), because it could be any component.



    I'm using TypeScript 3.1.6, Babel Core 7.1, and React 16.6.3.










    share|improve this question

























      2












      2








      2








      I'm trying to pass a variable of type React.Component (or React.FunctionComponent) into a Route, like this:



      import React from 'react';
      import { Route } from 'react-router-dom';

      type PrivateRouteProps = {
      component: React.Component | React.FunctionComponent;
      isAuthenticated: boolean;
      login: (...args: any) => any;
      path: string;
      };

      const PrivateRoute: React.FunctionComponent<PrivateRouteProps> = ({
      component: Component,
      isAuthenticated,
      login,
      path,
      ...rest
      }) => {
      return (
      <Route
      path={path}
      {...rest}
      render={props => {
      if (isAuthenticated) {
      return <Component {...props} />;
      } else {
      login();
      return null;
      }
      }}
      />
      );
      };


      But I'm getting this error:




      JSX element type 'Component' does not have any construct or call signatures. [2604]




      I've read through a bunch of other threads about this issue, but they all seem to deal with this error coming up for a specific component implementation. I can't change the component in question or import it differently (like the accepted answers often suggest), because it could be any component.



      I'm using TypeScript 3.1.6, Babel Core 7.1, and React 16.6.3.










      share|improve this question














      I'm trying to pass a variable of type React.Component (or React.FunctionComponent) into a Route, like this:



      import React from 'react';
      import { Route } from 'react-router-dom';

      type PrivateRouteProps = {
      component: React.Component | React.FunctionComponent;
      isAuthenticated: boolean;
      login: (...args: any) => any;
      path: string;
      };

      const PrivateRoute: React.FunctionComponent<PrivateRouteProps> = ({
      component: Component,
      isAuthenticated,
      login,
      path,
      ...rest
      }) => {
      return (
      <Route
      path={path}
      {...rest}
      render={props => {
      if (isAuthenticated) {
      return <Component {...props} />;
      } else {
      login();
      return null;
      }
      }}
      />
      );
      };


      But I'm getting this error:




      JSX element type 'Component' does not have any construct or call signatures. [2604]




      I've read through a bunch of other threads about this issue, but they all seem to deal with this error coming up for a specific component implementation. I can't change the component in question or import it differently (like the accepted answers often suggest), because it could be any component.



      I'm using TypeScript 3.1.6, Babel Core 7.1, and React 16.6.3.







      javascript reactjs typescript jsx






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 23 '18 at 21:09









      jacobsowlesjacobsowles

      67731039




      67731039
























          1 Answer
          1






          active

          oldest

          votes


















          3














          I have encountered this a couple of times. Try these:




          1. Type your PrivateRoute as React.SFC<Props>

          2. Type your incoming component as React.ReactType


          The ultimate truth about React types comes from the docs






          share|improve this answer
























          • #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

            – jacobsowles
            Nov 24 '18 at 2:47












          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452966%2ftypescript-3-jsx-element-type-component-does-not-have-any-construct-or-call-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          3














          I have encountered this a couple of times. Try these:




          1. Type your PrivateRoute as React.SFC<Props>

          2. Type your incoming component as React.ReactType


          The ultimate truth about React types comes from the docs






          share|improve this answer
























          • #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

            – jacobsowles
            Nov 24 '18 at 2:47
















          3














          I have encountered this a couple of times. Try these:




          1. Type your PrivateRoute as React.SFC<Props>

          2. Type your incoming component as React.ReactType


          The ultimate truth about React types comes from the docs






          share|improve this answer
























          • #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

            – jacobsowles
            Nov 24 '18 at 2:47














          3












          3








          3







          I have encountered this a couple of times. Try these:




          1. Type your PrivateRoute as React.SFC<Props>

          2. Type your incoming component as React.ReactType


          The ultimate truth about React types comes from the docs






          share|improve this answer













          I have encountered this a couple of times. Try these:




          1. Type your PrivateRoute as React.SFC<Props>

          2. Type your incoming component as React.ReactType


          The ultimate truth about React types comes from the docs







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 22:13









          Elias ToivanenElias Toivanen

          31016




          31016













          • #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

            – jacobsowles
            Nov 24 '18 at 2:47



















          • #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

            – jacobsowles
            Nov 24 '18 at 2:47

















          #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

          – jacobsowles
          Nov 24 '18 at 2:47





          #2 worked for me. Now it's time to do some research and figure out exactly why it worked. Thanks for the link to the docs, too.

          – jacobsowles
          Nov 24 '18 at 2:47




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452966%2ftypescript-3-jsx-element-type-component-does-not-have-any-construct-or-call-s%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Hercules Kyvelos

          Tangent Lines Diagram Along Smooth Curve

          Yusuf al-Mu'taman ibn Hud