Generator function is a function that can pause, accept some input and run again.

Invoking a generator function

Consider the printHello function which returns “Hello world”

function* printHello() {
  yield 'Hello world';
}

When a function has an asterix (*) as suffix, it becomes a generator function. How do we invoke a generator function?

const iterator = printHello();
let result = iterator.next();
Read More

There are lot of reasons to love React Hooks. But I have one reason that stands out from the rest.

Consider a class component that sets some state. This component has a controlled input within it.

class MyInput extends Component {
  state = { text: '' };

  render() {
    <input type="text" value={text} onChange={..} /}
}

With class components there are three ways to write onChange handler.…

Read More

Gatsby and NextJS are popular alternatives to create static websites using React. This tutorial shows how to work with Gatsby: use CSS modules to style, add a new page, navigate between pages, create a custom layout, add a plugin, process markdown files, use GraphQL and create custom pages.

Sample App Overview

The sample app is available in Netlify. There is a Home page which has a background image and a link to Services page.…

Read More