Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Crank.js uses generator functions for stateful components, where you yield instead of returning, and the scope is preserved for the lifetime of the component. You could technically use `while (true)`, but `for (props of this)` is the idiomatic way to get new props. The `this` object is an iterable of the latest props, and if the component doesn’t have props, `for ({} of this)` is the idiomatic way to loop over props without needing another variable assignment.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: