-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stateless function components for jsx #4861
Comments
//cc: @RyanCavanaugh |
But |
This needs a spec if we're going to do automatic inference from it. As @Lenne231 points out, the example posted doesn't seem to be how it works. Given the example from the release notes: var Aquarium = ({species}) => (
<Tank>
{getFish(species)}
</Tank>
); We could type this fairly easily: // Put this somewhere
interface ReactStateless<T> extends React.Component<T, {}> {
(props: T): JSX.Element;
}
var Aquarium: ReactStateless<{species: string}> = ({species}) => (
<Tank>
{getFish(species)}
</Tank>
); |
Is there a reason why we are currently not inferring the valid JSX components and the matching JSX properties from the type JSX = typeof React.createElement
// Type of valid JSX components: type of the first parameter of JSX
// Type of matching JSX properties: first generic parameter of JSX |
There will probably be a third kind of component in the future, so it would be nice if the implementation is flexible enough to handle that: |
Fleshing out the design at #5478 |
ReactJS gets stateless function components https://facebook.github.io/react/blog/2015/09/10/react-v0.14-rc1.html
How does it work with the current JSX support in TypeScript? It would be nice if something like this would work as well:
The text was updated successfully, but these errors were encountered: