3 ms·
Two corrections: 1. You can use types with React, either via Flow or in TypeScript with TSX. Unlike with Angular, with React you can also get type checking eve
by spion 11y ago
Two corrections:
1. You can use types with React, either via Flow or in TypeScript with TSX. Unlike with Angular, with React you can also get type checking even in the JSX template (checking for valid component property types included, even with TypeScript)
2. You can "externalise" your render method if you really want to by simply writing
import MyComponentTemplate from './external-template.tsx'
let MyComponent = React.createClass({
..
render: MyComponentTemplate
..
})
then in external-template.tsx
export default function render() {
return <template goes here>....
}
Most React users think its unnecessary, but it doesn't mean its not possible.
- tlrobinson 11y agoReact v0.14 adds "stateless functional components" syntax, which essentially makes your external-template.tsx a valid component on its own (with the caveat that no state or lifecycle methods are allowed): https://facebook.github.io/react/blog/2015/10/07/react-v0.14.html https://facebook.github.io/react/blog/2015/10/07/react-v0.14...
- tracker1 11y agoThere seems to be progression into breaking apart components that have decision trees with components that are simply rendered... I've had a tendency to favor this myself. Also, simple components can defer events to prop/parent binding.