No he’s actually correct, blaze will only update one element if a single item changes in a long cursor.
So if you do the following:
console.log(JSON.stringify(<ul><li>hello</li><li>world</li></ul>, null, " "));
It prints out this:
{
"type": "ul",
"key": null,
"ref": null,
"_owner": null,
"_context": {},
"_store": {
"props": {
"children": [
{
"type": "li",
"key": null,
"ref": null,
"_owner": null,
"_context": {},
"_store": {
"props": {
"children": "hello"
},
"originalProps": {
"children": "hello"
}
}
},
{
"type": "li",
"key": null,
"ref": null,
"_owner": null,
"_context": {},
"_store": {
"props": {
"children": "world"
},
"originalProps": {
"children": "world"
}
}
}
]
},
"originalProps": {
"children": [
{
"type": "li",
"key": null,
"ref": null,
"_owner": null,
"_context": {},
"_store": {
"props": {
"children": "hello"
},
"originalProps": {
"children": "hello"
}
}
},
{
"type": "li",
"key": null,
"ref": null,
"_owner": null,
"_context": {},
"_store": {
"props": {
"children": "world"
},
"originalProps": {
"children": "world"
}
}
}
]
}
}
}
This is a React Element. It is separate from any React Component instance, which represents what’s currently in the DOM. If a React Component’s render()
returns this React Element, the React Element is compared with the current state of the React Component to determine what needs to be updated. Then the real DOM is updated accordingly.
So if you return a <ul>
containing 100 <li>
tags in render()
it does create 1 parent React Element with 100 child React Elements and compares them all with the React Component tree.
In his posts he assumes the opposite and “hopes” blaze would only update 1 element at a time. So he’s arguing based on wrong assumptions. That’s why he’s wrong.
That’s good to know, when I was more worried about performance I was almost tempted to stick with pure Blaze for this reason, though luckily I haven’t run into any performance issues with React.
Another step towards React Maintainability ?
http://blogs.msdn.com/b/typescript/archive/2015/09/16/announcing-typescript-1-6.aspx
And some link for webpack boilerplate non-Meteor. Seems TS compile errors are not reaching browser error screen yet. https://github.com/plisy/typescript-react-transform-boilerplate
JSX support in Typescript is cool, you can define an interface for each component props so that you are warned when the parent is not passing the correct props. Also you can define an interface for state so that each this.state members are correctly accessed.
However, AFAIK meteor own this.data interface definition is not implemented and i don’t know if it can be done easily.