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;
}
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
add a comment |
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
add a comment |
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
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
javascript reactjs typescript jsx
asked Nov 23 '18 at 21:09
jacobsowlesjacobsowles
67731039
67731039
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I have encountered this a couple of times. Try these:
- Type your
PrivateRoute
asReact.SFC<Props>
- Type your incoming component as
React.ReactType
The ultimate truth about React types comes from the docs
#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
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
I have encountered this a couple of times. Try these:
- Type your
PrivateRoute
asReact.SFC<Props>
- Type your incoming component as
React.ReactType
The ultimate truth about React types comes from the docs
#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
add a comment |
I have encountered this a couple of times. Try these:
- Type your
PrivateRoute
asReact.SFC<Props>
- Type your incoming component as
React.ReactType
The ultimate truth about React types comes from the docs
#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
add a comment |
I have encountered this a couple of times. Try these:
- Type your
PrivateRoute
asReact.SFC<Props>
- Type your incoming component as
React.ReactType
The ultimate truth about React types comes from the docs
I have encountered this a couple of times. Try these:
- Type your
PrivateRoute
asReact.SFC<Props>
- Type your incoming component as
React.ReactType
The ultimate truth about React types comes from the docs
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
add a comment |
#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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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