Javascript (3)


Tips for making reusable React components

Tip 1: props.children

Instead of invoking the component with a self-closing tag <Picture /> if you invoke it will full opening and closing tags <Picture> </Picture> you can then place more code between it and display using this.props.children (props.children for stateless components) . This decouples the <Picture> component from its content and makes it more reusable. Tip 2: Stateless Components […]




Generator Functions in Javascript

We will be building on what we discussed in previous post generator-functions-using-co Here we will focus on how to implement something analogous to co. i.e. actually implement an iterable. How to run the function* Steps involved in running through a generator function. If its a bit confusing, it will be clear when we look at the […]




Generator Functions using co

Generator functions are a concept lifted likely from Python where they are used heavily in applications like web-crawlers. There are no prerequisites to this article but if you had an idea about Python generators, its the exact same concept implemented in Javascript. Definition Generators are functions which can be exited and later re-entered. Their context […]