How do I create a High-Order React Component connected to Redux using Typescript?
I need to create a React High-Order component to protect routes in my app against users that don't have an access token. Then using that HOC wrap a Component like this on parent component:
<Route
exact
path={INDEX_URL}
render={isAuthenticated((props: any) => (<LandingPage {...props} />))}
/>
I'm using Typescript and I'm having some issues with the connect function and withRouter from react-router-dom.
Can someone help me, please?
Thank you and have a great weekend! 😀
I've already tried to extend my interface with RouterProps and/or withRouter but none worked. It seems that is some typing related issue, but I can't figure out exactly what it is.
import * as React from 'react';
import { Redirect, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import * as H from 'history';
// Constants
import { LOGIN_URL } from '../../../data/constants/index.constants';
interface IAuthenticatedProps {
accessToken: string | null;
location: H.Location;
}
interface IAuthenticatedState {
isAuthenticated: boolean | undefined;
}
/**
* @description Higher-order component (HOC) to wrap Authenticated pages
* @date 2019-01-18
* @class Authenticated
* @extends {React.Component<IAuthenticatedProps, any>}
*/
const isAuthenticated = (ComposedComponent: any) => {
class Authenticated extends React.Component<
IAuthenticatedProps,
IAuthenticatedState
> {
(...)
function mapStateToProps(state: any) {
return {
accessToken: state.authentication.accessToken,
};
}
return withRouter(connect(mapStateToProps)(Authenticated));
};
export default isAuthenticated;
I expected no issues, but Typescript is giving me this:
[ts]
Argument of type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
Type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
Type 'Component<Pick<IAuthenticatedProps, "location">, any, any>' is not assignable to type 'Component<RouteComponentProps<any, StaticContext, any>, any, any>'.
Types of property 'props' are incompatible.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<any, StaticContext, any>>'.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is missing the following properties from type 'Readonly<RouteComponentProps<any, StaticContext, any>>': history, match [2345]
javascript reactjs typescript redux react-router
add a comment |
I need to create a React High-Order component to protect routes in my app against users that don't have an access token. Then using that HOC wrap a Component like this on parent component:
<Route
exact
path={INDEX_URL}
render={isAuthenticated((props: any) => (<LandingPage {...props} />))}
/>
I'm using Typescript and I'm having some issues with the connect function and withRouter from react-router-dom.
Can someone help me, please?
Thank you and have a great weekend! 😀
I've already tried to extend my interface with RouterProps and/or withRouter but none worked. It seems that is some typing related issue, but I can't figure out exactly what it is.
import * as React from 'react';
import { Redirect, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import * as H from 'history';
// Constants
import { LOGIN_URL } from '../../../data/constants/index.constants';
interface IAuthenticatedProps {
accessToken: string | null;
location: H.Location;
}
interface IAuthenticatedState {
isAuthenticated: boolean | undefined;
}
/**
* @description Higher-order component (HOC) to wrap Authenticated pages
* @date 2019-01-18
* @class Authenticated
* @extends {React.Component<IAuthenticatedProps, any>}
*/
const isAuthenticated = (ComposedComponent: any) => {
class Authenticated extends React.Component<
IAuthenticatedProps,
IAuthenticatedState
> {
(...)
function mapStateToProps(state: any) {
return {
accessToken: state.authentication.accessToken,
};
}
return withRouter(connect(mapStateToProps)(Authenticated));
};
export default isAuthenticated;
I expected no issues, but Typescript is giving me this:
[ts]
Argument of type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
Type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
Type 'Component<Pick<IAuthenticatedProps, "location">, any, any>' is not assignable to type 'Component<RouteComponentProps<any, StaticContext, any>, any, any>'.
Types of property 'props' are incompatible.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<any, StaticContext, any>>'.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is missing the following properties from type 'Readonly<RouteComponentProps<any, StaticContext, any>>': history, match [2345]
javascript reactjs typescript redux react-router
add a comment |
I need to create a React High-Order component to protect routes in my app against users that don't have an access token. Then using that HOC wrap a Component like this on parent component:
<Route
exact
path={INDEX_URL}
render={isAuthenticated((props: any) => (<LandingPage {...props} />))}
/>
I'm using Typescript and I'm having some issues with the connect function and withRouter from react-router-dom.
Can someone help me, please?
Thank you and have a great weekend! 😀
I've already tried to extend my interface with RouterProps and/or withRouter but none worked. It seems that is some typing related issue, but I can't figure out exactly what it is.
import * as React from 'react';
import { Redirect, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import * as H from 'history';
// Constants
import { LOGIN_URL } from '../../../data/constants/index.constants';
interface IAuthenticatedProps {
accessToken: string | null;
location: H.Location;
}
interface IAuthenticatedState {
isAuthenticated: boolean | undefined;
}
/**
* @description Higher-order component (HOC) to wrap Authenticated pages
* @date 2019-01-18
* @class Authenticated
* @extends {React.Component<IAuthenticatedProps, any>}
*/
const isAuthenticated = (ComposedComponent: any) => {
class Authenticated extends React.Component<
IAuthenticatedProps,
IAuthenticatedState
> {
(...)
function mapStateToProps(state: any) {
return {
accessToken: state.authentication.accessToken,
};
}
return withRouter(connect(mapStateToProps)(Authenticated));
};
export default isAuthenticated;
I expected no issues, but Typescript is giving me this:
[ts]
Argument of type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
Type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
Type 'Component<Pick<IAuthenticatedProps, "location">, any, any>' is not assignable to type 'Component<RouteComponentProps<any, StaticContext, any>, any, any>'.
Types of property 'props' are incompatible.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<any, StaticContext, any>>'.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is missing the following properties from type 'Readonly<RouteComponentProps<any, StaticContext, any>>': history, match [2345]
javascript reactjs typescript redux react-router
I need to create a React High-Order component to protect routes in my app against users that don't have an access token. Then using that HOC wrap a Component like this on parent component:
<Route
exact
path={INDEX_URL}
render={isAuthenticated((props: any) => (<LandingPage {...props} />))}
/>
I'm using Typescript and I'm having some issues with the connect function and withRouter from react-router-dom.
Can someone help me, please?
Thank you and have a great weekend! 😀
I've already tried to extend my interface with RouterProps and/or withRouter but none worked. It seems that is some typing related issue, but I can't figure out exactly what it is.
import * as React from 'react';
import { Redirect, withRouter } from 'react-router-dom';
import { connect } from 'react-redux';
import * as H from 'history';
// Constants
import { LOGIN_URL } from '../../../data/constants/index.constants';
interface IAuthenticatedProps {
accessToken: string | null;
location: H.Location;
}
interface IAuthenticatedState {
isAuthenticated: boolean | undefined;
}
/**
* @description Higher-order component (HOC) to wrap Authenticated pages
* @date 2019-01-18
* @class Authenticated
* @extends {React.Component<IAuthenticatedProps, any>}
*/
const isAuthenticated = (ComposedComponent: any) => {
class Authenticated extends React.Component<
IAuthenticatedProps,
IAuthenticatedState
> {
(...)
function mapStateToProps(state: any) {
return {
accessToken: state.authentication.accessToken,
};
}
return withRouter(connect(mapStateToProps)(Authenticated));
};
export default isAuthenticated;
I expected no issues, but Typescript is giving me this:
[ts]
Argument of type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to parameter of type 'ComponentType<RouteComponentProps<any, StaticContext, any>>'.
Type 'ConnectedComponentClass<typeof Authenticated, Pick<IAuthenticatedProps, "location">>' is not assignable to type 'ComponentClass<RouteComponentProps<any, StaticContext, any>, any>'.
Type 'Component<Pick<IAuthenticatedProps, "location">, any, any>' is not assignable to type 'Component<RouteComponentProps<any, StaticContext, any>, any, any>'.
Types of property 'props' are incompatible.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is not assignable to type 'Readonly<{ children?: ReactNode; }> & Readonly<RouteComponentProps<any, StaticContext, any>>'.
Type 'Readonly<{ children?: ReactNode; }> & Readonly<Pick<IAuthenticatedProps, "location">>' is missing the following properties from type 'Readonly<RouteComponentProps<any, StaticContext, any>>': history, match [2345]
javascript reactjs typescript redux react-router
javascript reactjs typescript redux react-router
edited Jan 18 at 20:32
JoaoTMDias
asked Jan 18 at 19:00
JoaoTMDiasJoaoTMDias
134
134
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
withRouter()
has the effect of providing props to the component that it wraps. Therefore, in order to use it, the component you want to wrap has to expect those props. In this case, Authenticated
is only expecting IAuthenticatedProps
, but withRouter()
provides many more. So TypeScript is complaining because withRouter()
is trying to provide props to Authenticated
that Authenticated
doesn't say it expects.
The props that withRouter()
provides are defined in the interface RouteComponentProps
. Try adding that to your prop type for Authenticated
:
class Authenticated extends React.Component<
IAuthenticatedProps & RouteComponentProps<{}>,
IAuthenticatedState
> {
// ...
}
You can also remove location
from your IAuthenticatedProps
interface as that is also included in the RouteComponentProps
interface.
One more problem is that the render
prop in Route
expects a function, not any old React component type. Since isAuthenticated()
returns a React.ComponentClass
, you'll need to do something like the following:
const Authenticated = isAuthenticated(LandingPage);
// ...
<Route
exact
path={INDEX_URL}
render={(props: any) => <Authenticated {...props} />}
/>
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
|
show 4 more comments
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%2f54259987%2fhow-do-i-create-a-high-order-react-component-connected-to-redux-using-typescript%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
withRouter()
has the effect of providing props to the component that it wraps. Therefore, in order to use it, the component you want to wrap has to expect those props. In this case, Authenticated
is only expecting IAuthenticatedProps
, but withRouter()
provides many more. So TypeScript is complaining because withRouter()
is trying to provide props to Authenticated
that Authenticated
doesn't say it expects.
The props that withRouter()
provides are defined in the interface RouteComponentProps
. Try adding that to your prop type for Authenticated
:
class Authenticated extends React.Component<
IAuthenticatedProps & RouteComponentProps<{}>,
IAuthenticatedState
> {
// ...
}
You can also remove location
from your IAuthenticatedProps
interface as that is also included in the RouteComponentProps
interface.
One more problem is that the render
prop in Route
expects a function, not any old React component type. Since isAuthenticated()
returns a React.ComponentClass
, you'll need to do something like the following:
const Authenticated = isAuthenticated(LandingPage);
// ...
<Route
exact
path={INDEX_URL}
render={(props: any) => <Authenticated {...props} />}
/>
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
|
show 4 more comments
withRouter()
has the effect of providing props to the component that it wraps. Therefore, in order to use it, the component you want to wrap has to expect those props. In this case, Authenticated
is only expecting IAuthenticatedProps
, but withRouter()
provides many more. So TypeScript is complaining because withRouter()
is trying to provide props to Authenticated
that Authenticated
doesn't say it expects.
The props that withRouter()
provides are defined in the interface RouteComponentProps
. Try adding that to your prop type for Authenticated
:
class Authenticated extends React.Component<
IAuthenticatedProps & RouteComponentProps<{}>,
IAuthenticatedState
> {
// ...
}
You can also remove location
from your IAuthenticatedProps
interface as that is also included in the RouteComponentProps
interface.
One more problem is that the render
prop in Route
expects a function, not any old React component type. Since isAuthenticated()
returns a React.ComponentClass
, you'll need to do something like the following:
const Authenticated = isAuthenticated(LandingPage);
// ...
<Route
exact
path={INDEX_URL}
render={(props: any) => <Authenticated {...props} />}
/>
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
|
show 4 more comments
withRouter()
has the effect of providing props to the component that it wraps. Therefore, in order to use it, the component you want to wrap has to expect those props. In this case, Authenticated
is only expecting IAuthenticatedProps
, but withRouter()
provides many more. So TypeScript is complaining because withRouter()
is trying to provide props to Authenticated
that Authenticated
doesn't say it expects.
The props that withRouter()
provides are defined in the interface RouteComponentProps
. Try adding that to your prop type for Authenticated
:
class Authenticated extends React.Component<
IAuthenticatedProps & RouteComponentProps<{}>,
IAuthenticatedState
> {
// ...
}
You can also remove location
from your IAuthenticatedProps
interface as that is also included in the RouteComponentProps
interface.
One more problem is that the render
prop in Route
expects a function, not any old React component type. Since isAuthenticated()
returns a React.ComponentClass
, you'll need to do something like the following:
const Authenticated = isAuthenticated(LandingPage);
// ...
<Route
exact
path={INDEX_URL}
render={(props: any) => <Authenticated {...props} />}
/>
withRouter()
has the effect of providing props to the component that it wraps. Therefore, in order to use it, the component you want to wrap has to expect those props. In this case, Authenticated
is only expecting IAuthenticatedProps
, but withRouter()
provides many more. So TypeScript is complaining because withRouter()
is trying to provide props to Authenticated
that Authenticated
doesn't say it expects.
The props that withRouter()
provides are defined in the interface RouteComponentProps
. Try adding that to your prop type for Authenticated
:
class Authenticated extends React.Component<
IAuthenticatedProps & RouteComponentProps<{}>,
IAuthenticatedState
> {
// ...
}
You can also remove location
from your IAuthenticatedProps
interface as that is also included in the RouteComponentProps
interface.
One more problem is that the render
prop in Route
expects a function, not any old React component type. Since isAuthenticated()
returns a React.ComponentClass
, you'll need to do something like the following:
const Authenticated = isAuthenticated(LandingPage);
// ...
<Route
exact
path={INDEX_URL}
render={(props: any) => <Authenticated {...props} />}
/>
edited Jan 18 at 22:02
answered Jan 18 at 20:40
ethan.rodayethan.roday
1,074619
1,074619
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
|
show 4 more comments
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
Great, that helped on the HOC component side, thanks! 💪 However, on the parent component Typescript now throws me another error: (Gee, I'm sorry I'm a n00b at commenting 😅)
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
[ts]Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' is not assignable to type '(props: RouteComponentProps<any, StaticContext, any>) => ReactNode'. Type 'ComponentClass<Pick<Pick<IAuthenticatedProps & RouteComponentProps<{}, StaticContext, any>, "location" | "history" | "match" | "staticContext">, never>, any>' provides no match for the signature '(props: RouteComponentProps<any, StaticContext, any>): ReactNode'
– JoaoTMDias
Jan 18 at 21:34
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Can you give an example of how you're calling from the parent component?
– ethan.roday
Jan 18 at 21:37
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Ah never mind I see your issue. I will update my answer.
– ethan.roday
Jan 18 at 21:45
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
Of course, here it goes: gist.github.com/JoaoTMDias/d11d44f220bd4c9515c8d53b84227b11
– JoaoTMDias
Jan 18 at 21:46
|
show 4 more comments
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%2f54259987%2fhow-do-i-create-a-high-order-react-component-connected-to-redux-using-typescript%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