Created
March 22, 2018 16:50
-
-
Save alecmerdler/18013e41ee9e25621d99e30a78a1ae3e to your computer and use it in GitHub Desktop.
Does TSX suck?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as React from 'react'; | |
import h = React.createElement; | |
export const TestComponentTSX: React.SFC<TestComponentProps> = (props) => { | |
return <div className="col-md-3"> | |
{ props.items.map((item, key) => <span key={key}> | |
Item {key + 1}: {item.name} | |
</span>) } | |
<input /> | |
<button onClick={() => console.log('Clicked!')}>Create</button> | |
</div>; | |
}; | |
export const TestComponent: React.SFC<TestComponentProps> = (props) => { | |
return h('div', {className: 'col-md-3'}, | |
props.items.map((item, key) => h('span', {key}, | |
`Item ${key + 1}: ${item.name}`)), | |
h('input', {}), | |
h('button', {className: 'btn btn-primary', onClick: () => console.log('Clicked!')}, | |
'Create')) | |
}; | |
export type TestComponentProps = { | |
items: {name: string}[]; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment