You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var Hi:React.StatelessComponent<{}> =
(props)=><h1>User info</h1>;
Everything is fine so far.
But when you try to use it inside another component like:
var Hello:React.StatelessComponent<{}> =
(props)=> <div><Hi></div>;
you will get an error (where you tried to use the Hi component):
Error:(9, 3) TS2605:
JSX element type 'ReactElement<any>' is not a constructor function for JSX elements.
Property 'render' is missing in type 'ReactElement<any>'.
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the @types modules in DefinitelyTyped.
To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the definitely-typed channel.
Activity
pdeva commentedon Jan 3, 2016
pinging @vsiao since he seems to be the one who added the type definition for
StatelessComponentvsiao commentedon Jan 4, 2016
Sorry, I don't use JSX/TSX. Maybe @RyanCavanaugh can help you.
tomenden commentedon Jan 13, 2016
@pdeva did you find a way to solve this issue?
SethDavenport commentedon Feb 21, 2016
@pdeva - I believe this has been fixed in TypeScript 1.8 - they improved their TSX to handle stateless components.
stroborobo commentedon Mar 18, 2016
Right, that's fixed in 1.8:
microsoft/TypeScript#5675
There's still a problem with children though:
Could make that optional though, or is there a nicer way?
Strato commentedon Apr 14, 2016
I bumped into the children error and it's annoying. Does anyone know how I can circumvent it until it's being fixed?
I've been looking for a way to cast a JSX component to any, to no avail.
Something like:
stroborobo commentedon Apr 14, 2016
@Strato What about optionals as I suggested? Better than casting stuff to
any. You know, like this:Strato commentedon Apr 14, 2016
I didn't understand this was possible. Thank you.
Hope it gets fixed soon in the definition, as it's a pretty common pattern.
orta commentedon Jun 7, 2021
Hi thread, we're moving DefinitelyTyped to use GitHub Discussions for conversations the
@typesmodules in DefinitelyTyped.To help with the transition, we're closing all issues which haven't had activity in the last 6 months, which includes this issue. If you think closing this issue is a mistake, please pop into the TypeScript Community Discord and mention the issue in the
definitely-typedchannel.