react Hoc Component Decorator in Typescript The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceWhat is TypeScript and why would I use it in place of JavaScript?Loop inside React JSXcomponentDidMount method not triggered when using inherited ES6 react classProgrammatically navigate using react routerWarning: React component classes must extend React.Component when using ScalaJSTypescript React: Access component property typesReact rails component render errorReact renders unnecessary componentsmy slider is not working and showing no error and all images are appearing the pagehow to export React component from a typescript file

"... to apply for a visa" or "... and applied for a visa"?

Do warforged have souls?

Match Roman Numerals

Wall plug outlet change

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

University's motivation for having tenure-track positions

How does ice melt when immersed in water?

How to copy the contents of all files with a certain name into a new file?

Python - Fishing Simulator

Did God make two great lights or did He make the great light two?

How are presidential pardons supposed to be used?

How can I define good in a religion that claims no moral authority?

Make it rain characters

Road tyres vs "Street" tyres for charity ride on MTB Tandem

system() function string length limit

In horse breeding, what is the female equivalent of putting a horse out "to stud"?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Can the prologue be the backstory of your main character?

How should I replace vector<uint8_t>::const_iterator in an API?

Difference between "generating set" and free product?

First use of “packing” as in carrying a gun

Why can't wing-mounted spoilers be used to steepen approaches?

Does Parliament need to approve the new Brexit delay to 31 October 2019?

What is this lever in Argentinian toilets?



react Hoc Component Decorator in Typescript



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
The Ask Question Wizard is Live!
Data science time! April 2019 and salary with experienceWhat is TypeScript and why would I use it in place of JavaScript?Loop inside React JSXcomponentDidMount method not triggered when using inherited ES6 react classProgrammatically navigate using react routerWarning: React component classes must extend React.Component when using ScalaJSTypescript React: Access component property typesReact rails component render errorReact renders unnecessary componentsmy slider is not working and showing no error and all images are appearing the pagehow to export React component from a typescript file



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








1















I want a HOC Component as a Decorator do login check like this:



function Login() 
return (Component) =>
return class Login extends Component
componentDidMount()
console.log('doSometing')
super.componentDidMount()

render ()
return super.render()





export default Login


import * as React from 'react';
import './App.css';
import withLogin from './login'

import logo from './logo.svg';

@withLogin()
class App extends React.Component
public render()
return (
<div className="App">
<header className="App-header">
<img src=logo className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.tsx</code> and save to reload.
</p>
</div>
);



export default App;


But get Typescript error:




(7,1): Unable to resolve signature of class decorator when called as
an expression.
Type 'typeof Login' is not assignable to type 'typeof
App'.

Type 'Login' is missing the following properties from type 'App': context, setState, forceUpdate, props, and 2 more.











share|improve this question
























  • repl.it/repls/TremendousLuckyDisc

    – allen yang
    Mar 22 at 6:46











  • link 404. and where is withLogin?

    – Angelki
    Mar 22 at 10:09











  • repl.it/@allenyang1/TremendousLuckyDisc

    – allen yang
    Mar 25 at 3:12

















1















I want a HOC Component as a Decorator do login check like this:



function Login() 
return (Component) =>
return class Login extends Component
componentDidMount()
console.log('doSometing')
super.componentDidMount()

render ()
return super.render()





export default Login


import * as React from 'react';
import './App.css';
import withLogin from './login'

import logo from './logo.svg';

@withLogin()
class App extends React.Component
public render()
return (
<div className="App">
<header className="App-header">
<img src=logo className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.tsx</code> and save to reload.
</p>
</div>
);



export default App;


But get Typescript error:




(7,1): Unable to resolve signature of class decorator when called as
an expression.
Type 'typeof Login' is not assignable to type 'typeof
App'.

Type 'Login' is missing the following properties from type 'App': context, setState, forceUpdate, props, and 2 more.











share|improve this question
























  • repl.it/repls/TremendousLuckyDisc

    – allen yang
    Mar 22 at 6:46











  • link 404. and where is withLogin?

    – Angelki
    Mar 22 at 10:09











  • repl.it/@allenyang1/TremendousLuckyDisc

    – allen yang
    Mar 25 at 3:12













1












1








1








I want a HOC Component as a Decorator do login check like this:



function Login() 
return (Component) =>
return class Login extends Component
componentDidMount()
console.log('doSometing')
super.componentDidMount()

render ()
return super.render()





export default Login


import * as React from 'react';
import './App.css';
import withLogin from './login'

import logo from './logo.svg';

@withLogin()
class App extends React.Component
public render()
return (
<div className="App">
<header className="App-header">
<img src=logo className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.tsx</code> and save to reload.
</p>
</div>
);



export default App;


But get Typescript error:




(7,1): Unable to resolve signature of class decorator when called as
an expression.
Type 'typeof Login' is not assignable to type 'typeof
App'.

Type 'Login' is missing the following properties from type 'App': context, setState, forceUpdate, props, and 2 more.











share|improve this question
















I want a HOC Component as a Decorator do login check like this:



function Login() 
return (Component) =>
return class Login extends Component
componentDidMount()
console.log('doSometing')
super.componentDidMount()

render ()
return super.render()





export default Login


import * as React from 'react';
import './App.css';
import withLogin from './login'

import logo from './logo.svg';

@withLogin()
class App extends React.Component
public render()
return (
<div className="App">
<header className="App-header">
<img src=logo className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.tsx</code> and save to reload.
</p>
</div>
);



export default App;


But get Typescript error:




(7,1): Unable to resolve signature of class decorator when called as
an expression.
Type 'typeof Login' is not assignable to type 'typeof
App'.

Type 'Login' is missing the following properties from type 'App': context, setState, forceUpdate, props, and 2 more.








reactjs typescript






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 7:07









Pavel Smirnov

2,365818




2,365818










asked Mar 22 at 6:45









allen yangallen yang

61




61












  • repl.it/repls/TremendousLuckyDisc

    – allen yang
    Mar 22 at 6:46











  • link 404. and where is withLogin?

    – Angelki
    Mar 22 at 10:09











  • repl.it/@allenyang1/TremendousLuckyDisc

    – allen yang
    Mar 25 at 3:12

















  • repl.it/repls/TremendousLuckyDisc

    – allen yang
    Mar 22 at 6:46











  • link 404. and where is withLogin?

    – Angelki
    Mar 22 at 10:09











  • repl.it/@allenyang1/TremendousLuckyDisc

    – allen yang
    Mar 25 at 3:12
















repl.it/repls/TremendousLuckyDisc

– allen yang
Mar 22 at 6:46





repl.it/repls/TremendousLuckyDisc

– allen yang
Mar 22 at 6:46













link 404. and where is withLogin?

– Angelki
Mar 22 at 10:09





link 404. and where is withLogin?

– Angelki
Mar 22 at 10:09













repl.it/@allenyang1/TremendousLuckyDisc

– allen yang
Mar 25 at 3:12





repl.it/@allenyang1/TremendousLuckyDisc

– allen yang
Mar 25 at 3:12












0






active

oldest

votes












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%2f55294227%2freact-hoc-component-decorator-in-typescript%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















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%2f55294227%2freact-hoc-component-decorator-in-typescript%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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript